Question: Here's an approach to implementing the three classes and the main program for your basketball player project: Height Class: Create a Height class with two
Here's an approach to implementing the three classes and the main program for your basketball player project:
Height Class:
Create a Height class with two instance variables: feet and inches.
Make the class immutable by not providing setter methods.
Implement a constructor that accepts feet and inches as parameters and creates a Height object.
Implement a toInches method that returns the total height in inches feet inches
Implement a toString method that returns a string representation of the height in the format XY where X is feet and Y is inches normalized if Y
Player Class:
Create a Player class with three instance variables: name string height of type Height and age integer
Make the class immutable by not providing setter methods.
Implement a constructor that accepts name, height, and age as parameters and creates a Player object.
Main Program:
In the main program, create a list of Player objects, each representing a basketball player.
Calculate the average age of all players by summing up the ages and dividing by the number of players.
Initialize variables to keep track of the tallest player and their height.
Iterate through the list of players:
Check if the player's age is less than or equal to the calculated average age.If yes, compare their height to the current tallest player and update the tallest player if needed.
After iterating through all players, you'll have the tallest eligible player.
Print the name and height of the tallest eligible player.
This approach ensures that you have welldefined classes for Height and Player, and the main program handles the logic of finding the tallest player within the specified age criteria.
Remember to create instances of the classes and populate the player list with player objects before running the logic in the main program.
Includes Height class and all its required methods
Includes Player class and all its required methods
Includes Project class
Creates array list of Player objects
Correctly computes and outputs average age of players
Correctly determines and outputs the tallest player
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
