Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

-A- 1 Normal 1 No Spac. Heading 1 Heading 2 Title Paragraph Styles Description of the REQUIREMENT we are to program: Program starts running. User

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
-A- 1 Normal 1 No Spac. Heading 1 Heading 2 Title Paragraph Styles Description of the REQUIREMENT we are to program: Program starts running. User is invited to play a game. If user says YES, the game starts. User is told: You guess a number between 1 and 100. Coming with the Winning Algorithm is one of your Requirements. Let's implement our ALGORITHM for our Game: // in programming land: we refer to Stories as "requirements" // ROOT: A player walks into a casino and wants to play a game Il we need to create a Player and we need to create a GAME Player pl = new Player(); Game g! = new Game(: Il we must design the algorithm for how the player interacts with the GAME: Here is the Way a Game is going to go: (We are now designing the Algorithm: we are thinking through the various possibilities and imagining how we want our Story to be told in CODE). The Number must be [l to 100].We know that each of these things is going to be done in METHODS Computer guesses a number Player guesses a Number: How are we going to decide the Winner: If the player is within 10 of the computer's number: Player WINS Else Computer WINS Now that we have put together several methods and several classes. INSTRUCTIONS: Use the starter code that I provided to complete the coding and add additional classes. 9 import java.util.*; 10 11 public class MainApplication{ 12 13 public static void main(String[] args) { 14 Casino c = new Casino(); 15 c. OrganizeNewGame(); 16 } 17 } 18 19 class Casino 20 W in programming Land: we refer to Stories as "requirements" 21 V/ R001: A player walks into a casino and wants to play a game 22 w we need to create a Player and we need to create a GAME 23 Player pl - new player(); 24 Game gl = new Game; 25 W we must design the algorithm for how the player interacts with the GAME: 26 String userAnswers 27 Scanner c- new Scanner(System.in); W/System. in a standard input stream 28 29 public void OrganizeNew Be system.out.println("welcome to our casino: Would you like to play a game? (y)"); 31 32 useranswer = .nextLine(); 22 33 34 35 userAnswer - sc.nextLine(); if (userAnswer.equals("y")) { System.out.println("let's get started"); g1.PlayGame(); } else {System.out.println("Good bye!");} 36 87 38 39 1 1 } 3 class Game 1 Random rand = new Randon(); private int ComputerGuess - -1; public void PlayGame() { System.out.println("Guess a number from 1 to 100"); System.out.println("And I will guess a game"); System.out.println("If your guess is within 28 of my guess: then you win. Else I will win!") ComputerGuess - ComputerGuess(); System.out.println("Computer Guess is + ComputerGuess); * } public int ComputerGuess W implement the Algorithm to generate the computer's guess: // use a Random Number Generate int programGuess = rand.nextInt(100); return programGuess; Inbox 3 SAT am 21W Lava Framex drive.google.com/file/d/1WWFdDvdOYOQOILS ULTYAWO/View A la Casino Starter Code.png - X mo Starter Code.png Open wir daramet 18 System.out.println("Guess a number from 1 to 180"); 9 System.out.println("And I will guess a game"); System.out.println("If your guess is within 20 of my guess: then you win. E 1 2 ComputerGuess = ComputerGuess(); 3 System.out.println("Computer Guess is " + ComputerGuess); 5 public int ComputerGuess() { // implement the Algorithm to generate the computer's guess: // use a Random Number Generate int programGuess = rand.nextInt(100); 3 return programGuess; 31 4 1 class Player 5 6 W collect user's input 7 // compare it to the computer's guess B V you have to come up with the Winning Algorithm 1

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

DB2 11 The Ultimate Database For Cloud Analytics And Mobile

Authors: John Campbell, Chris Crone, Gareth Jones, Surekha Parekh, Jay Yothers

1st Edition

1583474013, 978-1583474013

More Books

Students also viewed these Databases questions

Question

Estimate Ni=[N/2] 1/i

Answered: 1 week ago

Question

What is meant by formal organisation ?

Answered: 1 week ago

Question

What is meant by staff authority ?

Answered: 1 week ago

Question

Discuss the various types of policies ?

Answered: 1 week ago

Question

Briefly explain the various types of leadership ?

Answered: 1 week ago

Question

Explain the need for and importance of co-ordination?

Answered: 1 week ago

Question

1. The evaluation results can be used to change the program.

Answered: 1 week ago

Question

5. To determine the financial benefits and costs of the program.

Answered: 1 week ago