Answered step by step
Verified Expert Solution
Question
1 Approved Answer
My code works fine all the way through and I made it so that whether user inputs O/o or P/p it makes it uppercase. But
My code works fine all the way through and I made it so that whether user inputs O/o or P/p it makes it uppercase.
But I'm trying to figure out how to make my switch statement do this:
- Ask the user whether, the user wants to attack your opponent or find the partner.
To implement this feature, you must declare an enumeration constant with values OPPONENT and PARTNER. The user enters O to choose your opponent, P to choose the partner. The user may enter the choice in uppercase or lowercase.
- Inside a switch-case block, implement the following features.
- If the user chose to attack the opponent
- Check if the user chose the correct location of the opponent by comparing the users selected location with the opponents actual location.
- If the user found the opponent, inform the user that the opponent has been struck with paint and the game has been won. (See SAMPLE OUTPUT 5)
- Check if the user chose the location of the partner.
- If the user found the partner, inform the user that the partner has accidentally been shot and the game is lost. (See SAMPLE OUTPUT 3)
- If the user neither found the opponent nor the partner, the user loses a try. Inform the user about the remaining number of tries.
- If all tries are over, inform the user that the game has been lost. (See SAMPLE OUTPUT 1)
- Check if the user chose the correct location of the opponent by comparing the users selected location with the opponents actual location.
- If the user chose to attack the opponent
- If the user chose to find the partner
- Check if the user chose the correct location of the partner by comparing the users selected location with the partners actual location.
- If the user found the partner, inform the user that the partner has been found
- Double the number of remaining tries (See SAMPLE OUTPUT 5)
- Check if the user chose the location of your opponent.
- If the user found the opponent, inform the user that the opponent has been accidentally alerted and the game is lost. (See SAMPLE OUTPUT 4)
- If the user neither found the opponent nor the partner, the user loses a try. Inform the user about the remaining number of tries.
- Make sure the user cannot cheat by repeatedly finding the same partner. If the user tries to cheat this way, the user loses a try. Provide a suitable message and reduce the number of tries by 1 in this scenario. (See SAMPLE OUTPUT 5)
- Check if the user chose the correct location of the partner by comparing the users selected location with the partners actual location.
HINT: To implement this feature, you can use a Boolean variable to track whether the partner has been found or not.
- If all tries are over, inform the user that the game has been lost. (See SAMPLE OUTPUT 2)
- If the user enters any other option
- Inform the user of the wrong choice
- Your program must keep on asking the user for the choice, until the entered choice is either an opponent or a partner.
This is my code:
switch (chosen) case '0': on WN OO 107 cout
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