No need to code. just #13 question and which class needs to be modified to accom
ID: 3594150 • Letter: N
Question
No need to code. just #13 question and which class needs to be modified to accommodate multiple games? explain.
This project walks you through the development of an application that uses classes and objects to play a simple version of roulette. Our simpler roulette wheel has 12 positions, numbered from 00, 0 to 10 (think about how to represent 00). We will assume that the even numbers on the roulette wheel are colored black, and the odd numbers are colored red. However, double zero (00) and zero (0) are colored green. There is only one roulette wheel (one game) available for this version. A player starts the game with $100 with a minimum bet of $1 and up to available money (integer value only). We will limit to only one bet per round and a player can quit any time. There are three classes set up for this program. Obtain the three files Roulette.java, Player.java, and Wheel.java from Canvas and modify them as specify below (be sure to add your name to each file).
1. In its present form, the program simply loops as long as the player responds that they want to play again. Carefully trace the processing as it currently exists. Compile and execute the program.
2. At the beginning of the loop inside the main method, insert a call to the makeBet method of the player object. At this point the makeBet method simply reads the amount of the bet and deducts it from the available funds. Notice that a bet amount is deducted from money as soon as a bet is made. Compile and test the program.
3. We need a check to ensure that the bet amount is valid (between 1 and the available money). Print an error message and re-prompt for invalid betting amount by inserting that check in the makeBet method. Compile and test the program, stressing all possibilities.
4. Note that there is currently no call to the method betOptions of the Wheel class, which prints the betting possibilities. User is not allowed to bet on zero, double zero, or green color. Create a new instance variable called betType in the Player class. Then insert a call to the betOptions method from the makeBet method and input a bet type into variable betType. Note that the method betOptions is static, therefore its invocation is through the Wheel class, not an instance. In fact, we’ll never create an object of the Wheel class. It is designed assuming there is only one roulette wheel in the game, and therefore all data in the class is static. Make sure to utilize public named constants from this class as much as possible. Compile and test this modification.
5. We need to make one more modification to the makeBet method. If the user wants to bet on a particular number, we must prompt for and read that number. Be sure to validate that number so it would be between Wheel.MIN_NUM and Wheel.MAX_NUM (1 and 10 in this case). Store it in a variable called number in the player object. Use the constant Wheel.NUMBER to test for that betType.
6. Note that some issues, like the bet options, are presented by the Wheel class, while others, like determining the number to bet, are handled by the Player class. Why is that?
7. We need to be able to spin the roulette wheel. Create a static method called spin in the Wheel class that determines and sets the ballPosition variable. Insert a call to the spin method in the main loop after the player makes the bet.
8. In the spin method, determine the color of the current ball position, and set the color variable of the Wheel class. Make it correspond to the RED, BLACK, or GREEN constants already defined in the Wheel class. At the end of the spin method, print the results of the spin: both color and number. Compile and test your program.
9. Create a static method called payoff in the Wheel class, which accepts parameters representing the bet amount, the bet type, and the number bet. Note that the third parameter is not needed if the bet is on color so the method just ignores the third parameter if applicable. The purpose of this method is to return the amount won by the player. The user automatically loses the bet on a zero or double zero. Because there are two types of payoff categories, we will need to determine the payoff amount correctly. If the bet is on a particular number and if the number bet matches the number on the wheel, the payoff is 10 times the bet (use NUMBER_PAYOFF); otherwise the payoff is zero. If the bet is on a color and if the color bet matches the color on the wheel, the payoff is 2 times the bet (use COLOR_PAYOFF); otherwise the payoff is zero.
10. Create a method called payment in the Player class that determines the winnings using the payoff method, prints the payoff amount, and adds it to the available money. Insert a call to payment in the main processing loop after the wheel is spun. Compile and test the program.
11. Modify the Player class so a player automatically gets another $100 (use RELOAD_AMOUNT) when current money ran out and the player wishes to continue. Each player must keep track if his/her total winning or losing amount. Add a method called displayStatus to display total winning or losing amount after a player is done with the game and this method should be called after the main loop in main. Hint: add an instance variable to keep track of total winning or losing amount and modify some methods in the class as needed.
12. Modify the main method so two players start and play the game simultaneously (a player can leave the game any time) and the game would stop when there is not any player left. Note: a new player cannot enter the game once the game is started.
13. Test the game thoroughly. Note that the chances of betting on a number and winning that bet are relatively small. How could we modify the program to facilitate the testing of this issue while still demonstrating confidence in the program’s logic?
Explanation / Answer
Here there are three classes
Roulette, Player and Wheel
Roulette class never used in this programme.
Player class used for player data.
Player amount and details will not change for new games so Player class need no modification but add new variables if required for new game (for example in this game betType variable created).
So you need to modify wheel class to accommodate multiple games.
Make modifications to Wheel class to accommodate multiple games. write a function for each game separately.
Now create a function in Main method to print list of games and let the player choose game.
As per the user choice call the function(game) from Wheel class.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.