Question
The game of 'LastStone' starts with a random number of stones between 15 and 30. Two players (you and computer) alternate turns and on each
The game of 'LastStone' starts with a random number of stones between 15 and 30. Two players (you and computer) alternate turns and on each turn may take either 1, 2, or 3 stones from the pile. The player forced to take the last stone loses. Create a 'LastStone' application that allows the user to play against the computer. In this version of the game, the application generates the number of stones each time you start a new game. The user goes first as shown in the example. Your output should display the number of stones the user and the computer takes. Please be clear with ONLY ONE ANSWER. Previous tutors have made me confused with multiple explanations.
The 'LastStone' application code should:
- prevent the user and the computer from taking an illegal number ofstones. Forexample, neither should be allowed totake three stones whenthere are only 1 or 2left.
- include an isValidEntry() method to check user input.
- include a generateStones() method that generates a random numberfrom 1 to 3 for thenumber of stones the computer draws.
- include separate userMove()method to handle the user's turn
- Include a separate computerMove() method to handle the computer'sturn
- Include a playLastStone() method to play the game
Application output should look similar to that shown below:
There are 19 stones. How many would you like? 2
There are 17 stones. The computer takes 2 stones.
There are 15 stones. How many would you like? 4
In valid entry!!How many would you like? 3
There are 12 stones. The computer takes 1 stones.
There are 11 stones. How many would you like? 3
There are 8 stones. The computer takes 1 stones.
There are 7 stones. How many would you like? 2
There are 5 stones. The computer takes 3 stones.
There are 2 stones. How many would you like? 1
There are 1 stones. The computer takes 1 stones.
The player beats the computer!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Answer Heres the Java code for the LastStone application import javautilR...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