Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Simplified Battleship Type Game - One Player Against Computer You are going to have three constants in your program: ROWS (10), COLS (10), SHIPLENGTH

C++ Simplified Battleship Type Game - One Player Against Computer You are going to have three constants in your program: ROWS (10), COLS (10), SHIPLENGTH (3), NUMSHIPS (7), and TURNS (you decide). Your program is going to start with a 10x10 grid of the capital letter "O". This can be read from a file, or generated, up to you, but it will be stored as one array. For example a 3x3 tic tac toe board could be stored as a 9 element array: char tictactoe = {'O','X','O','O','O','X','X','X','O'}; O X O O O X X X O You are going to place 7 random, horizontal ships in this grid. Those locations will be identified as an 'S' there instead of an 'O'. The ships will be 3 units long. You can not place the ship too close to the right edge because there won't be enough room. You should avoid this situation in your code however you choose. Here's an example of how your program might come up with a game board grid:

O O O S S S O O O O O O O O O O O O O O O S S S O O S S S O O O O O O O O O O O S S S O O O O O O O O O O O O O O S S S O O O O O O O O O O O S S S O O O O O O O O O O O O O O O O O O O O O O S S S O

You will prompt the player for a number of turns, to enter a row and column. You will use these numbers to determine if that location is occupied by open ocean, part of a ship, or already fired upon, and report that back to the player. If the player fires upon a ship, the grid at those coordinates will change from an 'S' to an 'H'. If the player fires and misses, the grid coordinates will change from an 'O' to a 'M'. If the player fires upon a location they've already tried, your program should inform them. If the user has fired upon all 3 parts of the ship they will be told they've sunk a ship and be awarded 1 point. If the player miraculously sinks all 7 ships, turns should stop. Your game should keep track of how many ships have been sunk by the player, 0-7, and that will be their final score. Their final score will be displayed at the end of the game. Bonus points if you can reveal the grid at the end of the game, along with its hits and misses. Must be in C++

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

The Database Experts Guide To SQL

Authors: Frank Lusardi

1st Edition

0070390029, 978-0070390027

More Books

Students also viewed these Databases questions

Question

=+8.8. Suppose that S = (0,1,2 ,... ], Poo =1, and f,o>0 for all i.

Answered: 1 week ago

Question

5. How would you describe your typical day at work?

Answered: 1 week ago

Question

7. What qualities do you see as necessary for your line of work?

Answered: 1 week ago