Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Code in C++: Create a class called WaterVehicle that has the following member variables to represent the ships: length of ship (in number of grid

Code in C++: Create a class called WaterVehicle that has the following member variables to represent the ships:

length of ship (in number of grid spaces)

starting grid location

horizontal or vertical orientation on grid

sunk (Boolean indicating whether the ship has been sunk or not)

You will also need to create a reasonable complement of member functions (constructors, accessor, and mutator functions) to create the ships, to set the location of the ship, get the location of the ship, determine if the ship was hit, and determine if the ship is sunk. Then create a Carrier, a Battleship, a Cruiser, a Submarine, and a Destroyer which are all of type WaterVehicle and have the following lengths: Ship Type Number of Grid Squares Carrier 5 Battleship 4 Cruiser 3 Submarine 3 Destroyer 2 Then write a program which will allow input of the ship length, grid location, and orientation. Assume the grid where the submarine is to be placed is a 10 by 10 grid and is indexed. Randomly generate 15 torpedo shots in the main of the program, output the shot grid locations to the screen, and then output whether the torpedo hit any ship and if it did, whether that ship was sunk. You will need private member variables to keep track of where a ship has been hit to understand if it has been sunk.

Finally overload the << operator to print a WaterVehicle with tabs between fields:

length of ship (in number of grid spaces)

starting grid location

horizontal or vertical orientation on grid

sunk (Boolean indicating whether the ship has been sunk or not)

Demonstrate the use of this operator for each WaterVehicle after the torpedos have been fired. Grading Rubric Follow best practices in programming with declarations in .h files and implementations in .cpp files. Creat a makefile (not makefile.txt!)

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

Secrets Of Analytical Leaders Insights From Information Insiders

Authors: Wayne Eckerson

1st Edition

1935504347, 9781935504344

More Books

Students also viewed these Databases questions

Question

16. Implement this MPEMP.

Answered: 1 week ago

Question

11. Store this politicalecological data in the data sets directory.

Answered: 1 week ago

Question

13. Place the results of this analysis in the out files directory.

Answered: 1 week ago