Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Assignment 7A: Ro-Sham-Bo. Believe it or not, the classic game of Rock-Paper- Scissors has many other names. One of them is Ro-Sham-Bo. For this assignment,

image text in transcribedimage text in transcribedimage text in transcribed
Assignment 7A: Ro-Sham-Bo. Believe it or not, the classic game of Rock-Paper- Scissors has many other names. One of them is Ro-Sham-Bo. For this assignment, "Ro" will represent "Rock", "Sham" will represent Paper, and "Bo" will represent Scissors. You will create a RoshamboPlayer class. It will have four attributes: PlayerName: String Attack: String . . . RoLimit: int ShamBoLimit: int It will also have an overloaded constructor that sets those three values. It will have three functions: playRound that takes in a string and returns a boolean value, getName that takes in nothing and returns the PlayerName string, getAttack that takes in nothing and returns the Attack string. In your driver class Assignment7A, you will create two RoshamboPlayer objects with the following values: p1: RoLimit == 30, ShamBoLimit = = 60 p2: RoLimit = 40, ShamBoLimit = 85 You may name them whatever you like. You will prompt the user to choose one of these two to play against. Then you will create a loop that prompt the user to either play a round of Roshambo, or quit the game. if the user chooses to play, prompt them to attack with either "Ro", "Sham", or "Bo". If the input is invalid, keep prompting them until they enter valid input. Once they've made a choice, pass the input to the RoshamboPlayer object's playRound function. This function should randomly generate the RoshamboPlayer's attack of "Ro",\"Sham", or \"Eto'. This is done by generating a random number between ID and 1GB, then comparing it with the FtoLimit and ShamboLimit values for the object. If the random value is between [i and RoLimit the object's attack is "Ro". If the random value is between FtoLimit and ShamboLimit, the object's attack is \"Sham". ll the random value is greater than ShamboLimit, the object's attack is \"Etc". The object's attack should then be saved in its Attack attribute once calculated. Compare the object's attack with the pmyersahack The playFtound function should return TRUE if the player 'won the match, and FALSE if the object won or there 1was a draw {which is considered a win for the object}. Lise that information to inform the player it they won or lost. Repeat the process until the player guns Sample Output: [Ro-Eham-Eo Player] who do you want to face? 1} R. Dorothy 2} Johnny 5 opponent: 1 your opponent is R. Dorothy! 1} PLay a round? 2} Quit? choice: 1 Enter an attack: Rock InyaLid attack! Enter an attack: Sham R. Dorothy chose Bo! you lose... 1} PLay a round? 2} Quit? choice: 1 Enter an attack: Bo R. Dorothy chose Sham! You win! 1} PLay a round? 2} Quit? choice: 1 Enter an attack: no R. Dorothy chose not You lose... \f

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

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions