Example #1
0
 // Parametrezid Singleton
 private BattleShipGame(BattleShipPlayer _first, BattleShipPlayer _second)
 {
     if (_first != null)
     {
         player1 = _first;
     }
     if (_second != null)
     {
         player2 = _second;
     }
 }
Example #2
0
 // Singleton + Builder
 public static BattleShipGame getInstance(BattleShipPlayer _first, BattleShipPlayer _second)
 {
     if (instance == null)
     {
         lock (syncRoot) // Is used in order to not to be ambiguity
                         // during execution of different threads...
         {
             if (instance == null)
             {
                 player1  = _first;  // player1 is of type BattleShipPlayer abstract class
                 player2  = _second; // player2 is of type BattleShipPlayer abstract class
                 instance = new BattleShipGame();
             }
         }
     }
     return(instance);
 }
Example #3
0
 public static void setPlayer2(BattleShipPlayer _second)
 {
     player2 = _second;
 }
Example #4
0
 public static void setPlayer1(BattleShipPlayer _first)
 {
     player1 = _first;
 }
Example #5
0
 private BattleShipGame()
 {
     player1 = player2 = null;
 }