Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
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
eyalbi authored May 30, 2020
1 parent 9c3d774 commit f9165f1
Show file tree
Hide file tree
Showing 5 changed files with 555 additions and 0 deletions.
17 changes: 17 additions & 0 deletions Battleship_game/Battleship.cpp
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++;
}
}
16 changes: 16 additions & 0 deletions Battleship_game/Battleship.h
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

};
Loading

0 comments on commit f9165f1

Please sign in to comment.