Question: Lab #1 Objectives for this lab: Deriving classes from parent classes Overriding methods Visibility when dealing with inheritance Object oriented design with abstract classes Creating
Lab #1
Objectives for this lab:
Deriving classes from parent classes
Overriding methods
Visibility when dealing with inheritance
Object oriented design with abstract classes
Creating an All Star Roster
For this lab you will be showing what youve learned about inheritance. You will need to complete the following steps:
Create a parent class called ProPlayerProPlayer should have the following specs:
A protected string variable to take in a players name
A private base salary variable set to a specified amount of your choosing.
A constructor that takes in the players name
A public method that returns the base salary you have defined
A method that prints the players name
An abstract method that for computing pay
Create a class called HockeyPlayer that is a child class of ProPlayerHockeyPlayer 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 players 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 parents method that prints the name but also includes the additional player info. (HINT: you should add to the parents print method by calling it inside the child method)
Create a main program class called AllStarRosterAllStarRoster should have the following specs:
A main method that creates and array of HockeyPlayer objects of size 6
Populate the 6 indexes with hockey player objects
Create a for each loop that will print all the player info you entered.
A sample output could look like this:
Sidney Crosby plays for the Penguins and makes $1250000 a year.
Jaromir Jagr plays for the Penguins and makes $1250000 a year.
Wayne Gretzky plays for the Kings and makes $2270300 a year.
Bobby Orr plays for the Bruins and makes $3776120 a year.
Doug Glatt plays for the Flyers and makes $515896 a year.
Mario Lemieux plays for the Penguins and makes $350000 a year.
Deliverables:
AllStarRoster.java
HockeyPlayer.java
ProPlayer.java
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
