Question
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
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 (you could use the grid class from the last assignment to hold the shot locations), 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.
This is C++ programming problem, is there someone to help me ?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started