Question: Assignment 3 Create a base class called WaterVehicle that has: length of ship (in number of grid spaces) starting grid location horizontal or vertical orientation

Assignment 3

Create a base class called WaterVehicle that has:

length of ship (in number of grid spaces)

starting grid location

horizontal or vertical orientation on grid

sunk (boolean)

Then create a class called Submarine that is derived from WaterVehicle and has the following additional properties:

dive depth

surfaced (Boolean)

Be sure your classes have a reasonable complement of constructors, accessor, and mutator methods including a public function to determine if the Submarine was hit by a torpedo and whether a hit sunk the ship. Additionally, create an overloaded assignment operator.

Write a program which will allow input of the ship length, grid location, orientation, and dive depth. Assume the grid where the submarine is to be placed is a 10 by 10 grid. Randomly generate 15 torpedo shots, output the shot grid locations to the screen and then output whether the submarine was hit or missed or sunk. The submarine should be the object to understand whether it was hit or sunk. Then create a second submarine and use your overloaded assignment operator to assign the values from the first submarine to the second submarine. Print out the information about the second submarine.

Please is there someone to help me on this problem, write the program on C++ ?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!