Question
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
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