Question: Code the following in Eclipse Sample OutPut: PROGRAM DESIGN Class Player Player -name String -score: ini rank. String +Player() +Player(String name) play): vold getScore(): Int



PROGRAM DESIGN Class Player Player -name String -score: ini rank. String +Player() +Player(String name) play): vold getScore(): Int -getRank: String +doc de Ranky: String +toString(): String Method Explanation: play will use a loop to generate a series of random numbers and add them to a total, which will be assigned to the variable score decideRank will set the instance variable rank to "level 1", "Level 2", "Level 3, "Level 4" based on the value of score, and return that string getScore will return score toString will return a string of name, score and rank. Must have all the accessors and mutators Class: Game Game -player: Player Game Player player) start(void -end vold decide Winner Player +ge Play | Player[] setPlayerPlayer player) String: String The instance variable is an array of Player Method Explanation constructor Game Player playerid will instantiate the instance variable with the passed Player array start will use a loop to go through each Player of the instance variable player (the array player(1) and have each element (which is a Player object) call the play method end print out "Game Ended. decide Winner use the score method of Player to get the score of each Player object in the instance variable player. Compare and decide the winner. Return the Player object Must have all the accessors and mutators Same Driver: main method will declare and instantiate an array of Player and create a Gane object with Then it will start the game (call the start method), end the game (call the end method). It will show the rank of each Player object and show the winner (you can call decide Winner in the print statement Since this method returns the winning Player object). Here is a summary in this main method, you are to call tart(), end(), and decide Winnerf) through the Game object you declared at the beginning Allthree methods are from the Game class GameDriver main(): vold Game Player -name: String -score: int -rank: String -player: Player +Game Player[] player) -start]vold *end): vold decide Winner(): Pbyer *gotPlayers) Plyor SetPlayer(Player player) Hosting) Suing +Player() -Player(String name) *playo): vold *getScore(); int -getRanki): String decideRankt): String toString): String Gate has started Player Jae Score: 44 Rank Level 2 Player Sam Scoro 30 Rank: Level 2 Player: Mary Score 55 Rankt Level 1 Player: sue Score 15 Rankt Level 4 Gate Has Ended. The winner Name Mary SOO055 Bank Level 1 Game has started Player Rex Score 34 Sankt Level 2 Playset ons Score 30 Pank: Level 2 Player Christy Scoret 23 Rank: Level Playert Colt Rankt Level Game hne Ended. The WENDY 100 MAMI Tann SOOTG30 Rankt Level Java Software Structures DESIGNING AND USING DATA STRUCTURES 41 Lewis Ana Chase
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
