Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In C++ program use the new style od C++ not the old one. Simple Battleship You will make a game similar to the classic board

In C++ program use the new style od C++ not the old one.

Simple Battleship

You will make a game similar to the classic board game Battleship. You will set up a 5 x 5, 2 dimensional array. In that array, you will use a random number generator to select 5 elements that will act as the placeholders for your "battleships". Your user will get 10 guesses to "seek and destroy" the battleships. After their 10 guesses, you will tell them how many ships they found. At some point during the program, you will need to display the game board (this is to assess your ability to traverse a 2 dimensional array).

Sample output (your program may vary in approach):

_______________________________

Welcome to Battleship! You have 10 chances to sink the 5 Battleships.

Enter a coordinate: 2 3 That is a miss! Enter a coordinate: 4 1 That is a hit! There are 4 remaining ships. Enter a coordinate: 5 5 That is a miss! Enter a coordinate: 3 2 That is a miss! Enter a coordinate: 1 1 That is a hit! There are 3 remaining ships. Enter a coordinate: 2 4 That is a miss! Enter a coordinate: 3 5 That is a miss! Enter a coordinate: 4 5 That is a miss! Enter a coordinate: 1 3 That is a hit! There are 2 remaining ships. Enter a coordinate: 3 3 That is a miss! You hit 3 out of 5 ships. ------------------------------------ 2 0 2 0 0 0 0 -1 -1 0 0 -1 -1 1 -1 2 0 0 -1 0 0 0 0 1 -1

2 = Hit, 1 = Ship, -1 = Missed shot

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

Automating Access Databases With Macros

Authors: Fish Davis

1st Edition

1797816349, 978-1797816340

Students also viewed these Databases questions

Question

What do Dimensions represent in OLAP Cubes?

Answered: 1 week ago