public class Player
{
/***************************************instance variables*/
private int id;
private String name;
private String team;
private String position;
private double salary, commissionRate;
/******************************************utility variables*/
Scanner input = new Scanner(System.in);
/***************************************constructors*/
public Player()
{
setId();
setName();
setTeam();
setPosition();
setSalary();
setCommissionRate();
}
public Player(int id, String name, String team, String position, double salary, double commissionRate)
{
this.id = id;
this.name = name;
this.team = team;
this.position = position;
this.salary= salary;
this.commissionRate = commissionRate;
}
/***************************************mutators*/
public void SetId()
{
System.out.print("Please enter id: ");
id = input.nextInt();
input.nextLine();
}
public void setId(int id)
{ this.id = id;}
public void SetName()
{
System.out.print("Please enter name of player: ");
name = input.nextLine();
}
public void setName(String name)
{ this.name = name; }
public void SetTeam()
{
System.out.print("Please enter team: ");
team = input.nextLine();
}
public void setTeam(String team)
{ this.team = team; }
public void SetPosition()
{
System.out.print("Please enter player's position: ");
position = input.nextLine();
}
public void setPosition(String position)
{ this.position = position; }
public void SetSalary()
{
System.out.print("Please enter player's salary: ");
salary = input.nextDouble();
input.nextLine();
}
public void setSalary(double salary)
{ this.salary = salary; }
public void SetCommissionRate()
{
System.out.print("Please enter commission rate of player: ");
commissionRate = input.nextDouble();
input.nextLine();
}
public void setCommissionRate(double commissionRate)
{ this.commissionRate = commissionRate; }
/***************************************accessors*/
public int getId()
{ return id; }
public String getName()
{ return name; }
public String getTeam()
{ return team; }
public String getPosition()
{ return position; }
public double getSalary()
{ return salary; }
public double getCommissionRate()
{ return commissionRate; }
/***************************************effectors*/
public double calcCommission()
{
double commission = salary * commissionRate;
return commission;
}
}//end of Player class
///errors read as
// setId(Int) in Player cannot be applied to () setID()
// error in every set constructor without argument
{
/***************************************instance variables*/
private int id;
private String name;
private String team;
private String position;
private double salary, commissionRate;
/******************************************utility variables*/
Scanner input = new Scanner(System.in);
/***************************************constructors*/
public Player()
{
setId();
setName();
setTeam();
setPosition();
setSalary();
setCommissionRate();
}
public Player(int id, String name, String team, String position, double salary, double commissionRate)
{
this.id = id;
this.name = name;
this.team = team;
this.position = position;
this.salary= salary;
this.commissionRate = commissionRate;
}
/***************************************mutators*/
public void SetId()
{
System.out.print("Please enter id: ");
id = input.nextInt();
input.nextLine();
}
public void setId(int id)
{ this.id = id;}
public void SetName()
{
System.out.print("Please enter name of player: ");
name = input.nextLine();
}
public void setName(String name)
{ this.name = name; }
public void SetTeam()
{
System.out.print("Please enter team: ");
team = input.nextLine();
}
public void setTeam(String team)
{ this.team = team; }
public void SetPosition()
{
System.out.print("Please enter player's position: ");
position = input.nextLine();
}
public void setPosition(String position)
{ this.position = position; }
public void SetSalary()
{
System.out.print("Please enter player's salary: ");
salary = input.nextDouble();
input.nextLine();
}
public void setSalary(double salary)
{ this.salary = salary; }
public void SetCommissionRate()
{
System.out.print("Please enter commission rate of player: ");
commissionRate = input.nextDouble();
input.nextLine();
}
public void setCommissionRate(double commissionRate)
{ this.commissionRate = commissionRate; }
/***************************************accessors*/
public int getId()
{ return id; }
public String getName()
{ return name; }
public String getTeam()
{ return team; }
public String getPosition()
{ return position; }
public double getSalary()
{ return salary; }
public double getCommissionRate()
{ return commissionRate; }
/***************************************effectors*/
public double calcCommission()
{
double commission = salary * commissionRate;
return commission;
}
}//end of Player class
///errors read as
// setId(Int) in Player cannot be applied to () setID()
// error in every set constructor without argument