-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
famous battleship game. the user will select number of subs that he wants and the computer will create a game board and battleships and will place them in a randomize way. the user will play turn by turn and also has options for hints.
- Loading branch information
Showing
5 changed files
with
555 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include "Battleship.h" | ||
int Battleship::ShipAmount = ZERO; | ||
Battleship::Battleship()///constroctor that uses the ship amount static variable to intialize ship lenth in order of creation | ||
{ | ||
if (ShipAmount > 4) { | ||
ShipLenth = 2; | ||
ShipAmount++; | ||
} | ||
else if (ShipAmount >= ZERO && ShipAmount < 4){ | ||
ShipLenth = 5 - ShipAmount; | ||
ShipAmount++; | ||
} | ||
else if(ShipAmount == 4) { | ||
ShipLenth = 3; | ||
ShipAmount++; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#include <iostream> | ||
#define ZERO 0 | ||
using namespace std; | ||
|
||
class Battleship { //class declaration | ||
private: | ||
int ShipLenth; //declaring private variables lenth and amount that is static | ||
static int ShipAmount; | ||
public: | ||
static int Get_Amount() { return ShipAmount; } //static method to get static value | ||
void Set_Lenth(int num) { ShipLenth = num; } //set func for lenth variable | ||
int Get_lenth() { return ShipLenth; } | ||
Battleship(); // default constroctor | ||
friend class Game; //friend class declaration | ||
|
||
}; |
Oops, something went wrong.