Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can anyone help ? I cant get the rank to change depending on their score . It just says level 1 . Java 1 package

Can anyone help ? I cant get the rank to change depending on their score . It just says level 1 . Java image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
1 package CHPP; 2 3 public class gameDriver { 4e public static void main(String[] args) { 5 Player() player = new Player (4); 6 player [0] = new Player("Joe"); 7 player [1] = new Player("Sam"); 8 player [2] = new Player("Mary"); 9 player (3] = new Player("Sue"); 10 11 Game game = new Game(player); 12 game.start(); 13 game.end(); 14 Player winner = game. decideWinner(); 15 System.out.printin("The winner is: " + winner); 16 17 Player() $1 = new Player [4]; 18 s1[6] = new Player("ben"); 19 s1[1] = new Player("jake"); 20 s1[2] = new Player("rose"); 21 s1[3] = new Player("mike"); 22 23 Game game1 = new Game(si); 24 game1.start(); 25 gamel.end(); 26 Player winner1 = game1.decideWinner(); 27 System.out.println("The winner is:in" + winneri); 28 29 } } 30 31 32 33 34 | "); Player.java Game.java x gameDriver.java 1 package CHPP; 3 public class Game { 4 private Player [] player; 5 6e public Game (Playerll player) 7 8 this.player = new Player (player. length]; 9 for(int i = 0; i max) { max = player[i].getScore(): index=1 42 43 44 45 46 return player(indexl; 48 49 50 Player.java X Game.java gameDriver.java public String getRank() { return rank; } public void setRank (String rank) { this. rank = rank; 38 390 40 41 42 43e 44 45 46 47e 48 49 50 51 52 53 54 55 56 57 58 59 60 61 public void play) int loopPick = (int) ((Math.random() * (10 - 5)) + 5); while(loopPick 10) loopPick (int) ((Math.random() * (10 - 5)) + 5); for(int i = 0; i 10) pick = (int) ((Math.random() * (10 - 5)) + 5); setScore(getScore() + pick): 62 63 64 65 666 67 68 69 70 71 72 73 74 75 public String decideRank() String r = ""; if(getScore() >= 10) r = "Level 1"; else if(getScore() >= 35 && getScore() = 20 && getScore() gameDriver (Java Application] /Library/Java/JavaVirtual Mac Player:Sam Score:47 Rank: Level 1 Player:Mary Score:63 Rank: Level 1 Player:Sue Score: 28 Rank: Level 1 Game Ended... The winner is: Player:Mary Score: 63 Rank: Level 1 Game has started Player:ben Score: 46 Rank: Level 1 Player:jake Score:58 Rank: Level 1 Player: rose Score:54 Rank: Level 1 Player:mike Score:33 Rank:Level 1 Game Ended... The winner is: Player: jake Score:58 Rank:Level 1 92:6:1486 103M of 256M 2 15 Player.java X Game.java gameDriver.java 1 package CHPP; 2. 3 import java.util. Random; 4 5 public class Player { 6 private String name; 7 private int score; 8 private String rank; 9 10e public player() 11 { 12 this.name = ""; 13 this. score = 0; 14 this.rank = "Level 1"; } 16 17e public Player(String name) { 18 this.name = name; 19 this.score = 0; 20 this.rank = "Level 1"; 21 } 22 23e public String stName() { 24 return name; 25 } 26 27e public void setName(String name) { 28 this.name = name; } 30 310 public int getScore() { 32 return score; 33 34 35 public void setScore(int score) { 36 this.score = score: 37 38 39 public String getRank { 40 return rank; 41 } 42 436 public void setRank(String rank) { this.rank = rank; 45 3 46 public void play() 48 { 49 int loopPick = (int) ((Math.random() 50 while(loopPick 18) 51 * (18 - 5)) + 5)

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

Recommended Textbook for

Concepts of Database Management

Authors: Philip J. Pratt, Joseph J. Adamski

7th edition

978-1111825911, 1111825912, 978-1133684374, 1133684378, 978-111182591

More Books

Students also viewed these Databases questions