Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a new Java Project called Midterm1. Add two packages to the src folder: p

ID: 672140 • Letter: C

Question

Create a new Java Project called Midterm1. Add two packages to the src folder: part1 and part2 Package part1: In package part1 declare 4 classes: Athlete, BaseballPlayer, SoccerPlayer and AthleteApp. Implement the classes based on the UML class diagram above. (AthleteApp includes the main method) Notice: the UML class diagram does not list overridden methods. I specify the expected behavior below and it your job to decide whether a method needs to be overridden or not In the main method do the following: Create an athlete named Rafael Nadal, a soccer player named Lionel Messi with position forward, and a baseball player named Ted Williams with a batting average of 0.344, and Create an array of Athletes and initialize it with the athlete, the soccer player and the baseball player. Loop through the array and print information about each of the athletes. Make each athlete practice. If the Athlete happens to be a soccer player make him head the ball. Print a new line before advancing to the next element in the array Note: AthleteApp doesn't call all methods. Still, every field, ctor(constructor), method specified in the UML class diagram needs to be implemented. Also: make sure to avoid code repetition (expected output is on next page)

Explanation / Answer

class Athlete { int i = 3; public static void main (String [] args) { Athlete obj1 = nee Athlete2 (); System.out.println ("obj1.i = " + obj1.i); obj1.printHello (); Athlete obj2 = new Athlete2 (); obj1.i = 5; System.out.println ("obj1.i = " + obj1.i); obj1.printHello (); System.out.println ("obj2.i = " + obj2.i); obj2.printHello (); } void printHello () { System.out.println ("Hello! i = " + i + " "); } }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote