Ro-Sham-Bo. Believe it or not, the classic game of Rock-PaperScissors 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 in C++. It will have three attributes: PlayerName: String RoLimit: int ShamBoLimit: int It will also have an overloaded constructor that sets those three values. It will have two functions: playRound that takes in a string and returns a boolean value, and getName that takes in nothing and returns the PlayerName string. In your driver class for this assignment, 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 “Bo”. This is done by generating a random number between 0 and 100, then comparing it with the RoLimit and ShamboLimit values for the object. If the random value is between 0 and RoLimit, the object’s attack is “Ro”. If the random value is between RoLimit and ShamboLimit, the object’s attack is “Sham”. If the random value is greater than ShamboLimit, the object’s attack is “Bo”. Compare the object’s attack with the player’s attack. The playRound function should return TRUE if the player won the match, and FALSE if the object won or there was a draw (which is considered a win for the object). Use that information to inform the player if they won or lost. Repeat the process until the player quits.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Ro-Sham-Bo. Believe it or not, the classic game of Rock-PaperScissors 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 in C++. It will have three attributes:

  • PlayerName: String
  • RoLimit: int
  • ShamBoLimit: int

It will also have an overloaded constructor that sets those three values. It will have two functions: playRound that takes in a string and returns a boolean value, and getName that takes in nothing and returns the PlayerName string.

In your driver class for this assignment, 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 “Bo”. This is done by generating a random number between 0 and 100, then comparing it with the RoLimit and ShamboLimit values for the object. If the random value is between 0 and RoLimit, the object’s attack is “Ro”. If the random value is between RoLimit and ShamboLimit, the object’s attack is “Sham”. If the random value is greater than ShamboLimit, the object’s attack is “Bo”. Compare the object’s attack with the player’s attack.

The playRound function should return TRUE if the player won the match, and FALSE if the object won or there was a draw (which is considered a win for the object). Use that information to inform the player if they won or lost. Repeat the process until the player quits.

Sample Output:
[Ro-Sham-Bo 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
Invalid 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: Ro
R. Dorothy chose Ro! You lose...
1) Play a round?
2) Quit?
Choice: 2
Game Over
Transcribed Image Text:Sample Output: [Ro-Sham-Bo 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 Invalid 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: Ro R. Dorothy chose Ro! You lose... 1) Play a round? 2) Quit? Choice: 2 Game Over
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
ADT and Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education