Question
Advanced Java Programming with Object-Oriented Programming Design VERY IMPORTANT NOTE!!: This program for the question below MUST USE at least 2 CLASSES, getters/setters, etc and
Advanced Java Programming with Object-Oriented Programming Design
VERY IMPORTANT NOTE!!: This program for the question below MUST USE at least 2 CLASSES, getters/setters, etc and other object-oriented design (OOD) concepts because I'm in a more advanced Java class that requires me to utilize the concepts mentioned above. Also, I need detailed, but brief comments to most, if not all of the code to explain what is being used in the code and what is does so I have a better understanding of the code. I've seen answers to the question below already posted, however they don't utilize object-oriented design (OOD) concepts such as a minumum of two classes, getters/setters, etc which is required for this advanced Java programming class. So please......answer the question and meet the requirements for this question. Basically, I need advanced Java object-oriented design concepts for simple programs so here's to hoping this works out and if it does, I'll give a thumbs up, I promise!!!
Modify the craps program of Fig. 6.8 to allow wagering. Initialize variable bankBalance to 1000 dollars. Prompt the player to enter a wager. Check that wager is less than or equal to bankBalance, and if its not, have the user reenter wager until a valid wager is entered. Then, run one game of craps. If the player wins, increase bankBalance by wager and display the new bankBalance. If the player loses, decrease bankBalance by wager, display the new bankBalance, check whether bankBalance has become zero and, if so, display the message "Sorry. You busted!" As the game progresses, display various messages to create some chatter, such as "Oh, you're going for broke, huh?" or "Aw c'mon, take a chance!" or "You're up big. Now's the time to cash in your chips!". Implement the chatter as a separate method that randomly chooses the string to display.
Sadly I can't post a picture of figure 6.8 for whatever reason so here's what I just pulled from a PDF containing the required figure. 6.8 I'm very sorry but this is the best I can do, I hope to God this helps otherwise I'm screwed as I don't know what else to do:
1 // Fig. 6.8: Craps.java 2 // Craps class simulates the dice game craps. 3 import java.util.Random; Fig. 6.8 | Craps class simulates the dice game craps. (Part 1 of 3.)
public class Craps 6 { 7 // create random number generator for use in method rollDice 8 private static final Random randomNumbers = new Random(); 9 10 11 12 13 // constants that represent common rolls of the dice 14 15 16 17 18 19 20 // plays one game of craps 21 public static void main( String[] args ) 22 { 23 int myPoint = 0; // point if no win or loss on first roll 24 25 26 27 28 // determine game status and point based on first roll 29 switch ( sumOfDice ) 30 { 31 32 33 34 break; 35 36 37 38 39 break; 40 41 42 43 System.out.printf( "Point is %d ", myPoint ); 44 break; // optional at end of switch 45 } // end switch 46 47 // while game is not complete 48 while ( ) // not WON or LOST 49 { 50 51 52 // determine game status 53 if ( sumOfDice == myPoint ) // win by making point 54 ; Fig. 6.8 | Craps class simulates the dice game craps. (Part 2 of 3.)
55 else 56 if ( sumOfDice == SEVEN ) // lose by rolling 7 before point 57 58 } // end while 59 60 // display won or lost message 61 if ( ) 62 System.out.println( "Player wins" ); 63 else 64 System.out.println( "Player loses" ); 65 } // end main 66 67 // roll dice, calculate sum and display results 68 69 { 70 // pick random die values 71 int die1 = 1 + randomNumbers.nextInt( 6 ); // first die roll 72 int die2 = 1 + randomNumbers.nextInt( 6 ); // second die roll 73 74 int sum = die1 + die2; // sum of die values 75 76 // display results of this roll 77 System.out.printf( "Player rolled %d + %d = %d ", 78 die1, die2, sum ); 79 80 81 } // end method rollDice 82 } // end class Craps
Output: Player rolled 5 + 6 = 11 Player wins Player rolled 5 + 4 = 9 Point is 9 Player rolled 4 + 2 = 6 Player rolled 3 + 6 = 9 Player wins Player rolled 1 + 2 = 3 Player loses Player rolled 2 + 6 = 8 Point is 8 Player rolled 5 + 1 = 6 Player rolled 2 + 1 = 3 Player rolled 1 + 6 = 7 Player loses Fig. 6.8 | Craps class simulates the dice game craps. (Part 3 of 3.) gameStatus = Status.LOST; gameStatus == Status.WON public static int rollDice() return sum; // return sum of dice
Step by Step Solution
There are 3 Steps involved in it
Step: 1
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