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
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:
![Problems @ Javadoc Console > SoccerTest [Java Application] C:\Program Files\Java\jre1.8.0_191\bin\javaw.exe (Nov 14,](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2022/08/6308a36761c45_5036308a36749120.jpg)
Problems @ Javadoc Console > SoccerTest [Java Application] C:\Program Files\Java\jre1.8.0_191\bin\javaw.exe (Nov 14, 2018, 10:03:00 AM) Player John Smith played 4 games. They started with the team on February 8, 2012. This player is a forward who scored 8 goals for an average of 2.0 goals per game. Player Robert Jones played 7 games. They started with the team on May 22, 2016. This player is a goalis who has 27 saves for an average of 3.9 savess per game. Player Frank Wright played 4 games. They started with the team on February 8, 2012. This player is a defenseman who has 14 tackles and has no red card. Player Joe Quinn played 8 games. They started with the team on February 8, 2012. This player is a defenseman who has 43 tackles and is sitting out with a red card.
Step by Step Solution
3.47 Rating (147 Votes )
There are 3 Steps involved in it
To achieve the desired output for your task youll need to implement classes in Java as described Heres a stepbystep implementation for each class followed by a test program Base Class SoccerPlayer jav... View full answer
Get step-by-step solutions from verified subject matter experts
