Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Purpose: Use multiple arrays to model multiple game boards. Description: Make in

ID: 3645900 • Letter: P

Question

Purpose: Use multiple arrays to model multiple game boards.

Description:
Make initial placement of player's ships/objects on their
boards for a game of Battleship.

If you are familiar with the board game Battleship this program
should function in a manner similar to the start of that game.

Note: You are not expected to have the entire game working
after this assignment but that is the direction you are headed.

If you aren't comfortable with the Battleship basis think of
it as a game of Hide-and-Seek. A printed description of the
game and the rules are available from Mr. Polzin.

Place all the ships for one player, then place the ships for
the other player. As each ship is placed display the board for
the current player showing the ships placed so far. After both
players have placed their ships, display both boards
side-by-side.

Input:
Expect the the placement of the ships to be entered as
a row letter, column number, and direction letter ('H'
or 'V' for horizontal or vertical.) Assume ships are
placed to the right or down from the initial row and
column. Place ships from longest to shortest.

Use meaningful prompts.

Ex:
--
Place carrier:
Row: A
Column: 1
Direction: H

Place battleship:
Row: A
Column: 6
Direction: V

...

Place destroyer:
Row: F
Column: 9
Direction: V

Remember, for this assignment you only need to initially place
the player's ships/objects on their board.
---------------------------------------------------------------
Notes:
- Use your functions from the previous assignment to assist
with the user input.
- Write functions to organize your program and eliminate
redundant code.
- Use incremental development. Make one board and get one
player's ships placed. Then add the second player.
- You could even just get the "board" working. Make a
board. Write a display function to display a board. You
could even write a "load" function to auto-load a board
for testing your display code.

- Try to remember where you are headed for the final product
when making design decisions about this particular
assignment.
---------------------------------------------------------------
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
The game: An overview of what we will eventually produce
--------
On two 10x10 grids place 5 different objects(ships). The
objects are various lengths and will therefore occupy
different numbers of adjacent spaces. The objects must lie
vertically or horizontally along one row or column. The goal is
to guess where all 5 of your opponent's objects are before your
opponent guesses where yours are. As you guess, you are told
if you've "found" a cell containing one of the "hidden" objects
and are told when you've completely found an entire object. The
objects are:
5 cell (aircraft carrier)
4 cell (battleship)
3 cell (cruiser)
3 cell (submarine)
2 cell (destroyer)

Our program will initially just coordinate the game between two
players. {Eventually it could be extended to allow one player
to play against the computer.} The program will allow the two
players to enter their objects initial positions. The program
will then read in guesses and display the results of each
guess. Both players "guess" boards will be displayed
simultaneously while they alternately guess. The positons of
the players objects will be stored by the program and will not
be displayed while players alternate guesses.

All input and display should take place in text mode for now.
{Eventually we will add graphics.} Initially allow each user a
turn to make initial placement of all their "hidden" objects'
locations. Then display their intially empty guess boards and
alternately prompt each user for their next guess and redisplay
the two boards showing where they have guessed and which
guesses were good or bad, hit or miss. Indicate when an object
is entirely found. When one player finally guesses the
locations of all the other player's objects have the program
declare a winner and fully display both boards. The rows are to
be identified with letters A-J and the columns by numbers 1-10.
A guess will then be a combination of a letter and a number
that identifies a row and column.

Explanation / Answer

#include using namespace std; int main() { int x; int y; int array[8][8]; // Declares an array like a chessboard for ( x = 0; x < 8; x++ ) { for ( y = 0; y < 8; y++ ) array[x][y] = x * y; // Set each element to a value } cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote