JAVA
Posted: Fri Apr 29, 2022 8:04 am
JAVA
A class called Team is shown in the following UML diagram. The purpose is to maintain a list of player names. Team - players [] : String - count: int + Team ( size : int) + getCount(): int + addPlayer ( name : String) + getPlayer (index: int): String + toString(): String a. Code just the attribute definitions for this class. (1 mark) b. The constructor has an integer parameter that is the size of the team to be allocated. Code just the constructor (2 marks) C. The addPlayer method has a string parameter that is the next player name to add to the team. Each time a player is added to the team, the count is incremented. If the team is already full an error message is issued instead. Code this method. (3 marks) d. Code the driver statements (not a whole main) to exercise the constructor and the addPlayer method. Assume that all the other methods have been coded and work as required. (3 marks)
A class called Team is shown in the following UML diagram. The purpose is to maintain a list of player names. Team - players [] : String - count: int + Team ( size : int) + getCount(): int + addPlayer ( name : String) + getPlayer (index: int): String + toString(): String a. Code just the attribute definitions for this class. (1 mark) b. The constructor has an integer parameter that is the size of the team to be allocated. Code just the constructor (2 marks) C. The addPlayer method has a string parameter that is the next player name to add to the team. Each time a player is added to the team, the count is incremented. If the team is already full an error message is issued instead. Code this method. (3 marks) d. Code the driver statements (not a whole main) to exercise the constructor and the addPlayer method. Assume that all the other methods have been coded and work as required. (3 marks)