Question
Create a java program called notGotRed which simulates 2 players playing the following game: A bag contains 2 red marbles and 9 green marbles. A
Create a java program called notGotRed which simulates 2 players playing the following game: A bag contains 2 red marbles and 9 green marbles. A player blindly picks one marble from the bag and returns the marble to the bag. If the selected marble is green, the player rolls 2 dice and adds the total face value of the dice to their score. If they roll a double (i.e. the face values are the same), the player's total score remains unchanged (i.e. a 0 score for that round). The player then picks a marble from the bag again, rolling again if a green marble is picked, and so on. The player's turn is finished when he picks a red marble. For example: Player 1 picks a green marble, rolls 4 and 3, picks a green marble again and rolls 2 and 2, picks a green marble again and rolls 2 and 5, then picks a red marble. Player 1 scores 14. Player 2 picks a green marble and rolls 6 and 4, then picks a red marble. Player 2 scores 10. Player 1 wins. Sample output 1: Player 1: 14 Player 2: 10 Player 1 wins Sample output 2: Player 1: 7 Player 2: 7 Tie
Instructions -Use integers to represent the colors, considering the amount marbles for each color -Your solution must include a method named displayWinner that accepts the player scores as parameters and does not have a return value. -The winning roll must be determined by using Math or Integer utility method - cannot use arrays or arraylists - cannot use try or catch methods
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