コード例 #1
0
ファイル: BattleShipGame.cs プロジェクト: VladGanuscheak/TMPS
 // Singleton
 public static BattleShipGame getInstance()
 {
     if (instance == null)
     {
         lock (syncRoot) // Is used in order to not to be ambiguity
                         // during execution of different threads...
         {
             if (instance == null)
             {
                 instance = new BattleShipGame();
             }
         }
     }
     return(instance);
 }
コード例 #2
0
ファイル: BattleShipGame.cs プロジェクト: VladGanuscheak/TMPS
 // 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);
 }
コード例 #3
0
ファイル: BattleShipGame.cs プロジェクト: VladGanuscheak/TMPS
 public void setToNull()
 {
     instance = null;
 }