Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is in C++ Now we'll write another class battleShip. If you're not familiar with the game, it might helpful to go read up on

This is in C++

image text in transcribed

Now we'll write another class battleShip. If you're not familiar with the game, it might helpful to go read up on it before doing this question. https://en.wikipedia.org/wiki/Battleship_(game) class battleShipt public: battleShip(string): battleShip); void setShipName(string): string getShipName); void setSize(int); int getSize); void recordHit; bool isSunk; // returns true if hits is greater than equal to size / Increments the hits data member private: string name; int size; int hits; d: For this question, we've provided a complete class definition in the coderunner box. Write the function definitions for all 8 member functions of the battleShip class. The constructor battleShip(string) takes the ship name and should set all the data members of the ship to the correct value. The default size of a ship should be -1. What should hits be set to for a new ship? The function recordHit() should print" has been hit times." For example, if a ship named "Carrier" with size 5 had 4 hits, I would expect the output "Carrier has been hit 4 times." The function isSunk0 should print " has been sunk." For example, if a ship named "Destroyer" has sunk, I would expect the output Destroyer has been sunk

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

Professional Microsoft SQL Server 2012 Administration

Authors: Adam Jorgensen, Steven Wort

1st Edition

1118106881, 9781118106884

More Books

Students also viewed these Databases questions

Question

=+2 Why are so many countries bothered by their brain drains?

Answered: 1 week ago