Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a class called HockeyPlayer that is a child class of ProPlayer HockeyPlay

ID: 3884804 • Letter: C

Question

Create a class called HockeyPlayer that is a child class of ProPlayer

                HockeyPlayer should have the following specs:

                                Variables to hold the team name of the player and the bonus pay of the player

                                A constructor that takes in and stores the player’s name(think super here), team name, and bonus pay

                                A method that returns the calculated pay of the player using the base pay plus the bonus pay.( the base pay needs to come from the parent class.

                                A method that overrides the parent’s method that prints the name but also includes the additional player info. (HINT: you should add to the parent’s print method by calling it inside the child method)

The Parent Class ProPlayer.java

public abstract class ProPlayer {
protected String name;
private float baseSalary=0;

public ProPlayer(String name) {
this.name = name;
}

public float getBaseSalary() {
return baseSalary;
}
  
public void printName(){
System.out.println(name);
}
  
abstract void computePay();
}

Explanation / Answer

NOTE : If you want to use computePay in you HockeyPlayer class to compute and return the pay then you should modify your ProPlayer class by modifying the method return type to float abstract float computePay();

ProPlayer.java

public abstract class ProPlayer {
protected String name;
private float baseSalary=0;
public ProPlayer(String name) {
this.name = name;
}
public float getBaseSalary() {
return baseSalary;
}
  
public void printName(){
System.out.println(name);
}
  
abstract float computePay(); // Changed return type from void to float
}

HockeyPlayer.java


public class HockeyPlayer extends ProPlayer {

String teamName;
float bonusPay;

public HockeyPlayer(String teamName, float bonusPay, String name) {
super(name);
this.teamName = teamName;
this.bonusPay = bonusPay;
}
  
public float calculatedPay(){
return this.bonusPay + super.getBaseSalary();
}

@Override
public void printName(){
System.out.println("Player : "+super.name );
System.out.println("Team Name : "+teamName);
System.out.println("Salary : "+this.computePay());
}
  
  
@Override
float computePay() {
return this.bonusPay + super.getBaseSalary();   
}
  
}

PLEASE RATE !!

Thanks!

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote