Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Is there another way to do this play() method ? Its suppse to be random numbers generated but I want to to look organized .

Is there another way to do this play() method ? Its suppse to be random numbers generated but I want to to look organized . Is there a simple way to do this ? im trying to get the score to be from 1-50 . Java . Let me know if i need to add more information . image text in transcribed
image text in transcribed
image text in transcribed
16 170 48 public void play() { int loopPick = (int) ((Math.random() * (10 - 5)) + 5); while(loopPick 10) { loopPick = (int) ((Math.random() * (10 - 5)) + 5); 49 50 51 52 53 54 55 56 57 58 59 60 61 for(int i = 0; i 10) { pick = (int) ((Math.random() * (10 - 5)) + 5); } setScore(getScore() + pick); } } 62 63 64 Player:Sam Score: 60 Rank: Level 1 Player:Mary Score: 46 Rank: Level 1 Player:Sue Score:49 Rank: Level 1 Game Ended.. The winner is: Player:Joe Score: 61 Rank:Level 1 Game has started Player:ben Score:55 Rank: Level 1 Player:jake Score: 65 Rank:Level 1 Player: rose Score: 45 Rank: Level 1 Player: mike Score:41 Rank: Level 1 Game Ended... The winner is: Player:jake Score: 65 Rank:Level 1 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_2

Step: 3

blur-text-image_3

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

Intranet And Web Databases For Dummies

Authors: Paul Litwin

1st Edition

0764502212, 9780764502217

More Books

Students also viewed these Databases questions

Question

How do modern Dashboards differ from earlier implementations?

Answered: 1 week ago