Answered step by step
Verified Expert Solution
Question
1 Approved Answer
import java.io.*; import java.util.Scanner; public class AFLPlayer extends AFLTeamMember { private int number; // number declared for the AFLPlayer private boolean isCaptain; // isCaptain declared
import java.io.*;
import java.util.Scanner;
public class AFLPlayer extends AFLTeamMember
{
private int number; // number declared for the AFLPlayer
private boolean isCaptain; // isCaptain declared for the AFLPlayer
public AFLPlayer (String name, String position, int number, boolean isCaptain) // AFLPlayer can extend the name and its position for the isCaptain
{
super (name, position); // super keyword used for the setting the name and its position for the AFLPlayer
setNumber (number); // set the number for the AFLPlayer
setCaptain(isCaptain); // isCaptain for extension for the AFLPlayer
}
public int getNumber () // getting the number
{
return number; // returning the number
}
public void setNumber (int number) //setting the number which is type of int for the AFLPlayer
{
try // try
{
if (number>0)
this.number = number;
else
throw new
Exception ("Invaid player number!"); // invalid player number
}
catch (Exception e) // catch the exception
{
System.out.println(e); // print out the exception
}
}
public boolean isCaptain () // isCaptain for the exceptional isCaptain
{
return isCaptain; // returning the isCaptain
}
public void setCaptain (boolean isCaptain); //setCaptain for the exceptional isCaptain
public String toString()
{
if(isCaptain)
return " [" +number+"]"
"+super.toString()+" (c);
return "["+number+"]
"+super.toString(); //returning the number
}
}
}
*******CAN ANYONE FIX THE ERRORS IN IT AMD TYPE THE RIGHT CODE FOR THIS*******
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started