Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Athlete.java package poly; public class Athlete extends Person { String team; int position; public Athlete(String name, int age, String team, int position) { super(name, age);

image text in transcribed

Athlete.java

package poly;

public class Athlete extends Person {

String team;

int position;

public Athlete(String name, int age, String team, int position) {

super(name, age);

this.team = team;

this.position = position;

}

}

Baseball.java

package poly;

public class Baseball extends Athlete{

String battingPosition;

public Baseball(String name, int age, String team, int position, String battingPosition) {

super(name, age, team, position);

this.battingPosition = battingPosition;

}

public void doThis() {

System.out.println("I hit something.");

}

@Override

public String toString() {

return "Baseball Player:"

+ " Name: "+ this.name

+ " Age: "+this.age

+ " Batting Position:" + battingPosition;

}

}

Football.java

package poly;

public class Football extends Athlete{

String speciality;

public Football(String name, int age, String team, int position, String speciality) {

super(name, age, team, position);

this.speciality = speciality;

}

public void doThis() {

System.out.println("I tackle something.");

}

@Override

public String toString() {

return "Football Player:"

+ " Name: "+ this.name

+ " Age: "+this.age

+" Speciality:" + speciality;

}

}

Golfer.java

package poly;

public class Golfer extends Athlete{

String sponser;

public Golfer(String name, int age, String team, int position, String sponser) {

super(name, age, team, position);

this.sponser = sponser;

}

public void doThis() {

System.out.println("I put it in the hole.");

}

@Override

public String toString() {

return "Golfer:"

+ " Name: "+ this.name

+ " Age: "+this.age

+ " Sponser:" + sponser;

}

}

Hockey.java

package poly;

public class Hockey extends Athlete{

String stickBrand;

public Hockey(String name, int age, String team, int position, String stickBrand) {

super(name, age, team, position);

this.stickBrand = stickBrand;

}

public void doThis() {

System.out.println("I sit in a penalty box.");

}

@Override

public String toString() {

return "Hockey Player:"

+ " Name: "+ this.name

+ " Age: "+this.age

+" Stick Brand:" + stickBrand;

}

}

Person.java

package poly;

public class Person {

String name;

int age;

public Person(String name, int age) {

super();

this.name = name;

this.age = age;

}

}

Test.java

package poly;

public class Test {

public static void main(String[] args) {

//objects

Baseball Regie = new Baseball("Joe", 26, "Yankees", 3,"Right handed");

Football Manning = new Football("Jeff", 30, "Jags", 6, "Linebacker");

Hockey Jordan = new Hockey("TuTu", 24, "Canada", 8, "Nike");

Golfer Tiger = new Golfer("Tiger", 27, "PGA", 5, "Nike");

Baseball Ortiz = new Baseball("Regie", 36, "Mets", 3,"Left Handed");

Football Girly = new Football("John", 30, "Rams", 6, "Runing Back");

Hockey Gretsky = new Hockey("Wayne", 34, "Capitals", 10, "Adidas");

Golfer Clint = new Golfer("Matt", 21, "PGA", 9, "Nike");

//doThis method

Regie.doThis();

Manning.doThis();

Jordan.doThis();

Tiger.doThis();

Ortiz.doThis();

Girly.doThis();

Gretsky.doThis();

Clint.doThis();

//string method by printing the objects

System.out.println(Regie);

System.out.println(Manning);

System.out.println(Jordan);

System.out.println(Tiger);

System.out.println(Ortiz);

System.out.println(Girly);

System.out.println(Gretsky);

System.out.println(Clint);

}

}

Java program

. 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 comment all polymorphic variable . You are to comment all polymorphic methods. . You are to comment all polymorphic method calls. o Remove the reference variables and replace them with an array called [100] people o The array people will be of type person o You are to load the array with the data below. Feel free to add extra people o Clean up the two string methods throughout the project. Make them neat and make them fit together 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. . 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 comment all polymorphic variable . You are to comment all polymorphic methods. . You are to comment all polymorphic method calls. o Remove the reference variables and replace them with an array called [100] people o The array people will be of type person o You are to load the array with the data below. Feel free to add extra people o Clean up the two string methods throughout the project. Make them neat and make them fit together 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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Illuminated

Authors: Catherine M. Ricardo, Susan D. Urban, Karen C. Davis

4th Edition

1284231585, 978-1284231588

More Books

Students also viewed these Databases questions