Create a class called SoccerPlayer Create 4 protected attributes: First Name, Last Name, Games and Start Date.
Question:
Create a class called SoccerPlayer
Create 4 protected attributes: First Name, Last Name, Games and Start Date. Start Date should be of type CustomDate1.
Have one constructor in SoccerPlayer
Accepts input of first name, last name, games and start date.
Create get and set methods for each of the first three attributes and a toString method.
Create 3 additional classes that extends SoccerPlayer. These three classes should be called Forward, Defense and Goalie. Each of these classes needs their own constructor that calls the Superclass constructor as well as fills in the new protected attributes for the class.
Class Forward should include two additional protected attributes for Goals Scored and Average Goals per game.
Create get and set method for goals
Create a method that calculates the average number of goals scored per game.
This method checks for zero games played:
If there are zero played, display an error and set average to 0;
If greater than zero, do the math and set average to result of calculation
Create a toString method that displays all of the inherited info, the number of total goals scored and the average number of goals per game displayed to one decimal place.
Class Goalie should include two additional protected attributes for Saves Made and Average Saves per game.
Create get and set method for Saves Made
Create a method that calculates the average number of saves per game.
This method checks for zero games played:
If there are zero played, display an error and set average to 0;
If greater than zero, do the math and set average to result of calculation
Create a toString method that displays all of the inherited info, the number of total saves and the average number of saves per game displayed to one decimal place.
Class Defense should include two additional protected attributes for total number of tackles and if the player has a red card (which should be a Boolean).
Create get and set method for both attributes
Create a toString method that displays all of the inherited info, the number of tackles and displays a message stating if the player is playing or is suspended due to a red card.
Create a test program called SoccerPlayerTest.
Create four instances of players.
The first should be a forward
The second should be a goalie
The third should be a defenseman who does not have a red card
The fourth should be a defensemen who does have a red card
Display the info about the players by calling the appropriate toString() methods.
Output: