Question
In C++ program use the new style od C++ not the old one. Simple Battleship You will make a game similar to the classic board
In C++ program use the new style od C++ not the old one.
Simple Battleship
You will make a game similar to the classic board game Battleship. You will set up a 5 x 5, 2 dimensional array. In that array, you will use a random number generator to select 5 elements that will act as the placeholders for your "battleships". Your user will get 10 guesses to "seek and destroy" the battleships. After their 10 guesses, you will tell them how many ships they found. At some point during the program, you will need to display the game board (this is to assess your ability to traverse a 2 dimensional array).
Sample output (your program may vary in approach):
_______________________________
Welcome to Battleship! You have 10 chances to sink the 5 Battleships.
Enter a coordinate: 2 3 That is a miss! Enter a coordinate: 4 1 That is a hit! There are 4 remaining ships. Enter a coordinate: 5 5 That is a miss! Enter a coordinate: 3 2 That is a miss! Enter a coordinate: 1 1 That is a hit! There are 3 remaining ships. Enter a coordinate: 2 4 That is a miss! Enter a coordinate: 3 5 That is a miss! Enter a coordinate: 4 5 That is a miss! Enter a coordinate: 1 3 That is a hit! There are 2 remaining ships. Enter a coordinate: 3 3 That is a miss! You hit 3 out of 5 ships. ------------------------------------ 2 0 2 0 0 0 0 -1 -1 0 0 -1 -1 1 -1 2 0 0 -1 0 0 0 0 1 -1
2 = Hit, 1 = Ship, -1 = Missed shot
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