Question: Using this information: import java.util.ArrayList; import java.util.Scanner; class Height { private final int feet; private final int inches; public Height ( int feet, int inches

Using this information: import java.util.ArrayList;
import java.util.Scanner;
class Height {
private final int feet;
private final int inches;
public Height(int feet, int inches){
this.feet = feet;
this.inches = inches;
}
public int toInches(){
return feet *12+ inches;
}
@Override
public String toString(){
int normalizedInches = inches %12;
return String.format("%d'%d\"", feet, normalizedInches);
}
}
class Player {
private final String name;
private final Height height;
private final int age;
public Player(String name, Height height, int age){
this.name = name;
this.height = height;
this.age = age;
}
public String getName(){
return name;
}
public Height getHeight(){
return height;
}
public int getAge(){
return age;
}
@Override
public String toString(){
return String.format("Name: %s, Height: %s, Age: %d", name, height.toString(), age);
}
}
public class Project1{
public static void main(String[] args){
Scanner scanner = new Scanner(System.in);
ArrayList players = new ArrayList<>();
int totalAge =0;
System.out.println("Enter player information (type 'done' to finish):");
while (true){
System.out.print("Name: ");
String name = scanner.nextLine();
if (name.equalsIgnoreCase("done")){
break;
}
System.out.print("Height (feet): ");
int feet = scanner.nextInt();
System.out.print("Height (inches): ");
int inches = scanner.nextInt();
scanner.nextLine(); // Consume the newline character
System.out.print("Age: ");
int age = scanner.nextInt();
scanner.nextLine(); // Consume the newline character
Height height = new Height(feet, inches);
Player player = new Player(name, height, age);
players.add(player);
totalAge += age;
}
if (!players.isEmpty()){
double averageAge =(double) totalAge / players.size();
System.out.println("Average Age of Players: "+ averageAge);
Player tallestPlayer = findTallestPlayer(players, averageAge);
System.out.println("Tallest Player: "+ tallestPlayer.toString());
} else {
System.out.println("No player information entered.");
}
}
private static Player findTallestPlayer(ArrayList players, double averageAge){
Player tallestPlayer = null;
int maxHeight =0;
for (Player player : players){
if (player.getAge()<= averageAge){
int totalHeight = player.getHeight().toInches();
if (totalHeight > maxHeight){
maxHeight = totalHeight;
tallestPlayer = player;
}
}
}
return tallestPlayer;
}
} write a. A UML class diagram that includes all classes you wrote. Do not include
predefined classes.
b. A test plan that includes test cases that you have created indicating what aspects
of the program each one is testing
c. A short paragraph on lessons learned from the project

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!