Question
The intent of this programing project is to allow you the opportunity to demonstrate your ability to solve problems using procedural C++ programming. This project
The intent of this programing project is to allow you the opportunity to demonstrate your ability to solve problems using procedural C++ programming. This project will focus on using loops, functions, random numbers, and arrays in the implementation of a modified version of the board game Battleship.
Program Description:
In this project, you will write a C++ program that simulates a modified version of the board game Battleship. In this implementation, there is only one player who tries to sink three ships (Destroyer, Submarine, and Battleship) that were randomly placed in a 6x6 grid (ocean) by the computer.
Design Specifications:
1) The program should first create the 6x6 grid (ocean) and place the three ships somewhere within this grid. The program should randomly select both the orientation (i.e. vertical or horizontal) and location for each ship. The Destroyer takes two positions, whereas the Submarine takes three and the Battleship takes four. Be sure that the location selected permits the placement of the ship into that location and that the ships do not overlap.
2) The program should then display the 6x6 grid and prompt the user to enter the coordinates of their guess (see below-left). If the coordinates are NOT within the range of acceptable values (i.e. row A-F and column 1-6), the program should display an error message (see below-right).
3) If the entered coordinates are legal, the program should check for the presents of a ship. a) If a ship is not present, the program should report a MISS (see below-left) and then re-display the 6x6 grid with a (M) at the location indicating a MISS (see below-right).
b) If a ship is present, the program should report a HIT (see below-left) and then re-display the 6x6 grid with a (H) at the location indicating a HIT (see below-right).
c) If the coordinates were already guessed, the program should report an ALREADY GUESSED message (see below-left) and should re-display the 6x6 grid (see below-right).
4) Continuing playing the game until a ship is sunk (i.e. {C 5 HIT}, {B 5 MISS}, {E 5 HIT}). These guesses found and sank the Battleship. After each guess, the program should re-display the 6x6 grid with the HITS and MISSES marked. After a ship is sunk, report that YOU SANK MY {ship} (see below-left) and then re-display the 6x6 grid (see below-right).
5) Continue playing the game until both the remaining ships are found and sunk. (SUBMARINE, see belowleft and DESTROYER, see below-right).
6) After all three ships are sunk, display the final 6x6 grid, report GAME OVER, the number of guesses required to find the ships, and the guess efficiency. Guess Efficiency equals (9/guess count) * 100% . Nine (9) is the minimum number of guesses required to sink the three ships (4+3+2). Guess count should include all guesses, including re-guesses.
While it is up to you to determine the best implementation, your design must utilize functions.
Arrays must be used.
NO global variables are allowed.
----------------------------------------------------------
Expand the grid to 8x8 and include Cruiser and Aircraft Carrier. The Cruiser takes three positions and the Aircraft Carrier takes five. For this option, your 8x8 grid should look like.
Improve the user interface by utilizing the system("PAUSE") and system("CLS") commands.
Create a header file (.h) and separate source files (.cpp) for each of your functions.
can someone help me with this this coding with 6 x 6 first then 8 x 8? also write comment so i know what the code is doing. please and thank you.
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