Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The exercises in this document practice Arrays of Objects and Array Lists of Objects Exercise 1: Write the following classes Class player: Implement the class
The exercises in this document practice Arrays of Objects and Array Lists of Objects Exercise 1: Write the following classes Class player: Implement the class Player that has a name (String), age (int), height (double), and best 3 scores (array of int) 1. 2. 3. 4. 5. Implement the constructors (default, initialization, and copy constructors) Implement the setters and getters for all attributes Implement the toString() method. Implement the equals() to determine if two players are equal to each other. Two players are considered equal if they have the same attributes 6. Implement the compareTo() method. Compare players according to their height. The compareTo) method returns either 0, 1, or -1 (just like the compareTo) method of the String class) Class Team 1. 2. 3. 4. 5. 6. 7. Implement the class Team that has a name (String), city (String), color (String), 5 players (array of Players) Implement the constructors to initialize the name, city and color. Implement the method addPlayerToTeam() that adds a player to the team Implement the method toString() that displays all attributes and all players information of the team Implement the method checkPlayer() that checks if a player is in the team or not. Implement the method removePlayerFromTeam() that removes a player from the array of Players Implement the method findMaxPlayer() that returns the tallest player in the team (Hint: using the compareTo() method of the Player class) Implement the method aboveAveragePlayers() that returns an array of Players with an average score greater than a given value that is passed as a parameter to the method. 8. Class TestTeam 1. Create two teams and initialize their attributes 2. Add 5 players to the first team and another 5 players to the second team 3. Display all players in both teams 4. Check if a certain player is in a certain team and display the appropriate message 5. Check if two players are equal to each other or not using the equals() method of the Player class 6. Remove a player from each of the two teams and display the player list of the teams after the removal 7. Display the tallest player in each team using the method findMaxPlayer() of the class Team 8. Display all players in each team who has an average score that is greater than 20 Exercise 2: Repeat the Team class (call it NewTeam) using ArrayLists of Player instead of Arrays of Players Create another test class, (call it TestNewTeam) and test the NewTeam class following the same steps as the TestTeam class The exercises in this document practice Arrays of Objects and Array Lists of Objects Exercise 1: Write the following classes Class player: Implement the class Player that has a name (String), age (int), height (double), and best 3 scores (array of int) 1. 2. 3. 4. 5. Implement the constructors (default, initialization, and copy constructors) Implement the setters and getters for all attributes Implement the toString() method. Implement the equals() to determine if two players are equal to each other. Two players are considered equal if they have the same attributes 6. Implement the compareTo() method. Compare players according to their height. The compareTo) method returns either 0, 1, or -1 (just like the compareTo) method of the String class) Class Team 1. 2. 3. 4. 5. 6. 7. Implement the class Team that has a name (String), city (String), color (String), 5 players (array of Players) Implement the constructors to initialize the name, city and color. Implement the method addPlayerToTeam() that adds a player to the team Implement the method toString() that displays all attributes and all players information of the team Implement the method checkPlayer() that checks if a player is in the team or not. Implement the method removePlayerFromTeam() that removes a player from the array of Players Implement the method findMaxPlayer() that returns the tallest player in the team (Hint: using the compareTo() method of the Player class) Implement the method aboveAveragePlayers() that returns an array of Players with an average score greater than a given value that is passed as a parameter to the method. 8. Class TestTeam 1. Create two teams and initialize their attributes 2. Add 5 players to the first team and another 5 players to the second team 3. Display all players in both teams 4. Check if a certain player is in a certain team and display the appropriate message 5. Check if two players are equal to each other or not using the equals() method of the Player class 6. Remove a player from each of the two teams and display the player list of the teams after the removal 7. Display the tallest player in each team using the method findMaxPlayer() of the class Team 8. Display all players in each team who has an average score that is greater than 20 Exercise 2: Repeat the Team class (call it NewTeam) using ArrayLists of Player instead of Arrays of Players Create another test class, (call it TestNewTeam) and test the NewTeam class following the same steps as the TestTeam class
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started