Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Q3. A. [7 pts.] Consider the following problem description. A football club has a name, city, and the number of players. Each player has an
Q3. A. [7 pts.] Consider the following problem description. 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. Develop java classes based on the description above and UML below. Club - Name: string -city: string +numOfPlayers: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 join Club Returns the player object in the format: Player: id=xxxx, Name:XXXX, Club{ name= xXXXX, city= xxxx, number of players=xxxx}} 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 Q3. B. [5 pts.] Define the main method in the class Q3Tester as follows, a. Based on 03-A, create and set the following objects: (2.5 pts) Reference Class Attributes Values Ci Name: Stars, City: Al Ain, Number of players =0 Name: Falcons, City: Abu Dhabi, Number of players=9 Player Name:Salim Ali, Id=1, club: Falcons Club C2 Club P1 b. Use the copy constructor to create a clone of the player Salim Ali. Call it P2. (0.5 pts.) c. Change the name player P2 to "Farooq Qasim". (0.5 pts.) d. Farooq wants to join the Falcons club, however, if he is not accepted then he wants to join the Stars. Write code to do that. (1 pts.) e. Print all attributes of player P2. (0.5 pts.)
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