QuestionQuestion

Modify the First Polymorphism Assignment as shown below.

• Include an Abstract Class and an Interface (add at least one abstract method)

• Modify your code to include Polymorphic Code (variables, methods, calls)

• You are to place your code inside a MS Word Document. You are to highlight in YELLOW all polymorphic variable.

• You are to highlight in GREEN all polymorphic methods.

• You are to highlight in BLUE all polymorphic method calls.

• Remove the reference variables and replace them with an array called people which can contain up to 100 elements.

• The array people will be of type person.

• You are to load the array with the data below. Feel free to add extra people.

• Clean up the two string methods throughout the project. Make them neat and make them fit together.

• A name is comprised of the following: firstName, middleInitial, lastName.

• A person has a name, and age.

• An athlete is a person. An athlete has a team and position.

• A baseball player is an athlete and a person.

• A football player is an athlete and a person.

• A hockey player is an athlete and a person.

• A golfer is an athlete and a person.

• A soccer player is an athlete and a person.

• Baseball players have a position.

• Football players may play defense or offense or special teams. A player can play multiple positions.

• A hockey player is a skater or a goalie (not both).

• A golfer has a sponsor.

• A soccer player has a position.

• All sport type objects have a method named doThis();

o Baseball -> doThis() displays I hit something.

o Football -> doThis() displays I tackle something.

o Hockey -> doThis() displays I sit in a penalty box.

o Golfer -> doThis() displays I putt it in the hole.

o Soccer -> doThis() displays I kick the ball.

o All sports have a doThis() method that displays something. The doThis() method must be name doThis() in all classes that have the method.

• Create the classes Person, Athlete, Baseball.

• Create the classes Football, Hockey, Golfer, Soccer.

• Create an equals methods for each Class.

• Create the doThis() method in each class.

• in main create and load the people array with the following:

o Hank H. Aaron: who is a baseball player (make up the rest...)

o Terry F. Bradshaw: a football player (make up the rest...)

o Mario Lemieux: a hockey player (make up the rest...)

o Paula X. Creamer: a golfer (make up the rest...)

o Brian T. Rowe: a soccer player (make up the rest...)

o Barry B. Bonds: a baseball player (make up the rest...)

o Payton A. Manning: a football player (make up the rest...)

o Wayne Gretzky: a hockey player (make up the rest...)

o Phil A. Mickleson: a golfer (make up the rest...)

o Dom A Dwyer: a soccer player (make up the rest...)

o add at least 6 or 12 more athletes

• Create equals methods for each class.

• By Sport, list the players that are equal to each other.

• Call each sports doThis() method (one at a time) passing each player.

• call the toString methods for each player object.

• Add a menu system that makes this all work.

Deliverables
1. In a short paragraph or two, explain the difference between Part 1 (the first Polymorphism Assignment) of your code and this Exam four changes (how you modified Part 1).

You can add this in a text file or Word file that you include in the project.

2. You are to turn in the updated UML with the project.

3. Do not worry about Word messing up your formatting. Just highlight where necessary.

4. Place the UML, paragraph, and the word document(s) in the SRC folder before you zip it up.

5. Design tool not required.

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

import java.util.Scanner;


public class TestPlayer {


public static void main(String[] args) {


Person personArray[] = new Person[100];


// Creating objects

Person Hank = new BaseballPlayer("Hank", "A.", "Aaron", 45, "Orlando Magic", "Batter1","lefthanded");

Person Terry = new FootballPlayer("Terry","F.", "Bradshaw", 30, " Los Angeles Rams ", "LeftWinger", FootballPlayer.Speciality.defense);

Person Mario = new HockeyPlayer("Mario", "R", "Lemieux", 53, "Pittsburgh Penguins", "Goalie", "CCW");

Person Paula = new Golfer("Paula", "X.", "Creamer", 32, "SkyGolf", "Unknown", "CDW");

Person Brain = new SoccerPlayer("Brain", "T.", "Rowe", 30, " Manchester City F.C ", "Number3", "Defender");

Person Barry = new BaseballPlayer("Barry", "B.", "Bonds", 45, "Pittsburgh Pirates", "Batter2","Both");

Person Payton = new FootballPlayer("Payton", "A.", "Manning", 30, "Argentina", "CornerBack", FootballPlayer.Speciality.offense);

Person Wayne = new HockeyPlayer("Wayne", "D", "Gretzky", 34, "New Jersey Devils", "Skater", "KTG");


Person Phil = new Golfer("Phil", "A.", "Mickleson", 49, "All-American ", "Unknown", "KPMG");

Person Dom = new SoccerPlayer("Dom ", "A", "Dwyer", 45, "Brazil ", "Number1", "GoalKeeper");

int index = 0;

personArray[index++] = Hank;

personArray[index++] = Terry;

personArray[index++] = Mario;

personArray[index++] = Paula;

personArray[index++] = Brain;

personArray[index++] = Barry;

personArray[index++] = Payton;

personArray[index++] = Wayne;

personArray[index++] = Phil;

personArray[index++] = Dom;

personArray[index++] = Dom;

int choice = 0;

Scanner scanner = new Scanner(System.in);

do {
System.out.println("Main Menu");
System.out.println("----------------------------");
System.out.println("1. By Sport, list the players that are equal to each other");
System.out.println("2. Call each sports doThis() method (one at a time) passing each player");
System.out.println("3. Call the toString methods for each player object");
System.out.println("0. Exit");
System.out.print("\nEnter your choice: ");

choice = scanner.nextInt();
//scanner.nextLine();

switch(choice) {

case 1:

for(int i = 0; i < index; i++) {

for(int j = 0; j < index; j++) {
if(i != j) {
if(perso...

By purchasing this solution you'll be able to access the following files:
Solution.docx and Person.zip.

$25.00
for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats