Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A football club has a name, city, and the number of players. Each player has an id, name and a club in which he/she plays

image text in transcribed

A football club has a name, city, and the number of players. Each player has an id, name and a club in which he/she plays for it. A player can join a club only if the number of players in that club is less than 12. A. Implement the two java classes based on the description above and UML below. B. Create a test class TestPlayer" to test your classes. a. Create a player p1, and give it an id and a name (the club should be initially null) and print it using its toString() method. b. Create another player p2, and give it another id and name and print it using toString(). c. Create a club c1. Give it a name, city. d. Set the club number of players to 11 and print the club using its toString() method. e. Make the first player p1 join the club. Print the player p1 and the club c1 using their toString() methods after the join. (Joining should pass) f. Make the second player p2 join the club. Print the player p2 and the club c1 using their toString() methods after the join. (Joining should fail) Club - Name: string -city: string +num OfPlayers:int +Club(string, string) +getCity():string +toString():string Player - playerld: int - Name: string -club: Club +Player(int, string) +Player(Player) +setName(string):void +toString():string +joinClub(Club):boolean Description Method Club class getCity toString Returns the city of the club Returns the club object in the format: Club{ name= xxxxx, city= xxxx, number of players=xxxx} Player class toString joinClub Returns the player object in the format: Player: id=xxxx, Name:xxxx, Club{ name= xxxxx, city=xxXX, number of playersxxxxx}} A player can join a club successfully if the number of players of the club is less than 12, otherwise the method returns false to indicate failure. In case joining is successful, the number of players of the old club of the player must be decremented by 1, the number of players of the new club must be incremented by 1, and the club attribute must be assigned the new club

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions