Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

NOTE : PLEASE DON'T COPY PASTE FROM OTHER EXPERTS NOTE 2 : Code In C++ PROGRAM: Program the game of battleship against the computer. Each

NOTE : PLEASE DON'T COPY PASTE FROM OTHER EXPERTS

NOTE 2 : Code In C++

PROGRAM:

Program the game of battleship against the computer. Each side has 2 grids. The first grid contains the location of the players ships. The second grid contains the location of the players shots and the outcome of the shot (hit or miss). The objective is to hit and sink all 5 enemy ships before they do the same to you. Each side receives ships listed in figure 1.

Figure 1:

The ships each side possesses. Each side gets 1 of each listed ship.

Class of Ship: Carrier | Battle ship | Cruiser | Submarine |Destroyer

Size : : 5 | 4 | 3 | 3 | 2

The human player will see 2 battlemaps every turn: 1) map of your ships and where the computer fired, 2) map of where you have fired and the result (hit something or miss).

Show the results of each turn enemy map indicating where the computer fired on you (and your ships) and a friendly map showing where you fired (and sunk) computer ships.

The grids are 10 x 10 squares. Use letter, number designation - columns are letters, rows numbers. Use whatever method is expedient to generate the computer moves; this isnt an AI class.

Pre programed ship placement (i.e. you can hard code the ship locations) is allowable.

You can use the Standard Template Library.

Make you code as reliable as possible.

Make your program output easy to read.

Style guide elements apply: comments, layout, Program Greeting, Source File Header, and variables etc. etc. Requirements.

This is a menu driven program. You can decide if it uses a numeric or alphabetic menu. Keep prompting and running until the quit option is selected.

Make you code as reliable as possible. Make your program output easy to read

Use functions whenever possible to modularize your code. Use function prototypes and code the functions under main().

Style guide elements apply: comments, layout, Program Greeting, Source File Header, and variables etc. etc.

"C" Specification Bundle.

1. // Specification C1 - OOP Use a Ship class, at a minimum. Put this comment above the class declaration.

2. // Specification C2 - Prohibit AI wasted shots Dont allow the computer to fire an squares its already fired on.

3. // Specification C3 - Secret Option Show the battlemaps from the computers perspective when a secret key is pressed. Extremely useful for debugging the program.

"B" Specification Bundle.

1. // Specification B1 - Validate Input Only allow valid map squares to be targeted.

2. //Specification B2 - Log file to Disk Record the battle in a time-stamped log file to disk. The timestamp should contain the run date and the time an activity occurred. Call the output file "log.txt".

3. // Specification B3 - Random Start Randomly place the computer ships. Check to make sure the placement is allowable, i.e. no ships crossing each other or going off the board.

"A" Specification Bundle.

1. // Specification A1 - Adv Input Validation Only allow the human to fire on squares not already fired upon

2. // Specification A2 - MultiFire Game This is a game option. Allow each side to fire once for each ship still afloat. Allow players to activate this option at the start of the game.

3. // Specification A3 - Cruise Missiles A modern update to the game. Each side fires as the original game, but instead of cannon shells, each side shoots cruise missiles. Each ship has a chance (80%) to shoot down incoming missiles (and report to you about it). Ships can only shoot down missiles targeted at their ship (i.e. if they dont shoot it down it will hit their ship). Similar to A2, this is an option you can set at the start of the game, OR ,

4. // Specification A3 - Random Human Start Allow the human player to place their ships. As with B2, make sure the placement is allowable.

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_2

Step: 3

blur-text-image_3

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

Larry Ellison Database Genius Of Oracle

Authors: Craig Peters

1st Edition

0766019748, 978-0766019744

More Books

Students also viewed these Databases questions

Question

5. Recognize your ability to repair and let go of painful conflict

Answered: 1 week ago

Question

=+j Explain the relationship between unions and MNEs.

Answered: 1 week ago

Question

=+Have they changed the way employees view IP?

Answered: 1 week ago