maincpp battleShiph In moodlecscoloradoedu 0 Recitation Acti
Solution
Hi friend, You have not given details about : recordHit and isSunk method; So I have goven dummy implementation.
Please fill this implementation according to question instruction(that you have not given in your post).
Please find other implementation:
############ battleShip.h ################
#ifndef BATTLESHIP_H
 #define BATTLESHIP_H
#include <iostream>
 using namespace std;
class battleShip{
   
    public:
        battleShip(string);
        ~battleShip();
       void setShipName(string);
        string getShipName();
       void setSize(int);
        int getSize();
       void recordHit();
        bool isSunk();
   private:
        string name;
        int size;
        int hits;
 };
#endif
################### battleShip.cpp ######################
#include <iostream>
 #include \"battleShip.h\"
using namespace std;
battleShip::battleShip(string n){
    name = n;
 }
battleShip::~battleShip(){
}
void battleShip::setShipName(string n){
    name = n;
 }
string battleShip::getShipName(){
    return name;
 }
void battleShip::setSize(int s){
    size = s;
 }
 int battleShip::getSize(){
    return size;
 }
void battleShip::recordHit(){
    hits = hits + 1;
 }
bool battleShip::isSunk(){
 // there is no hits/details in question about this implementation
    return false; // dummy
 }
################ main.cpp ####################
#include <iostream>
 #include \"battleShip.h\"
using namespace std;
int main(){
   // declaring three vaariables
    battleShip Destroyer(\"Destroyer-0\");
    battleShip Carrier(\"Carrier-0\");
    battleShip Cruiser(\"Cruiser-0\");
   // setting the ship size
    Destroyer.setSize(3);
    Carrier.setSize(10);
    Cruiser.setSize(2);
   while(Destroyer.isSunk() == false){
        Destroyer.recordHit();
    }
    return 0;
 }


