Question: c++ battleship program. need the game.cpp. the battleship.h is : #ifndef BATTLESHIP_H_ #define BATTLESHIP_H_ const int FLEET_SIZE=5; const int FIELD_SIZE=5; struct location{ int x; char

c++ battleship program. need the game.cpp.

the battleship.h is :

#ifndef BATTLESHIP_H_ #define BATTLESHIP_H_ const int FLEET_SIZE=5; const int FIELD_SIZE=5; struct location{ int x; char y; }; struct ship{ location loc; bool sunk; }; void initialize(ship[]); location pick(); bool match(ship, location); int check(const ship[], location); void deploy(ship[]); void printShip(ship); void printFleet(const ship[]); bool operational(const ship[]); location fire(); void sink(ship&); #endif

the battleship.cpp is:

#include #include #include #include "battleship.h" using std::cout; using std::cin; using std::endl; bool match(ship myShip, location mySpot){ // returns true if this location matches // the location of the ship // returns false otherwise if (myShip.loc.x == mySpot.x && myShip.loc.y == mySpot.y) return true; else return false; } int check(const ship myFleet[], location mySpot){ // returns the index of element of the array // that matches the location // returns -1 if none do for (int i = 0; i > mySpot.x >> mySpot.y; return mySpot; } void sink(ship& myShip) { myShip.sunk = true; }

c++ battleship program. need the game.cpp. the battleship.h is : #ifndef BATTLESHIP_H_#define BATTLESHIP_H_ const int FLEET_SIZE=5; const int FIELD_SIZE=5; struct location{ int x;char y; }; struct ship{ location loc; bool sunk; }; void initialize(ship[]);

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!