Exemple #1
0
 public static Cannon GetInstance()
 {
     lock (padlock) {
         if (cannonSingletonInstance == null) {
             cannonSingletonInstance = new Cannon();
         }
         return cannonSingletonInstance;
     }
 }
        static void Main(string[] args)
        {
            Console.WriteLine("Welcome to CannonAttack");
            bool isStillPlaying = true;

            while (isStillPlaying)
            {
                bool   isAHit = false;
                Cannon cannon = Cannon.GetInstance();
                while (!isAHit && cannon.Shots < MaxNumberOfShots)
                {
                    int angle;
                    int velocity;
                    Console.WriteLine(String.Format("Target is at {0} meters", cannon.DistanceOfTarget));
                    GetInputVariable(out angle, out velocity);
                    var shot = cannon.Shoot(angle, velocity);
                    isAHit = shot.Item1;
                    Console.WriteLine(shot.Item2);
                }
                isStillPlaying = GetIsPlayingAgain();
                cannon.Reset();
            }
            Console.WriteLine("Thanks for playing Cannon Attack");
        }
        static void Main(string[] args)
        {
            CannonInstance = Cannon.GetInstance();

            Play();
        }
Exemple #4
0
 public static void CannonTestInitialize(TestContext testContext)
 {
     cannon = Cannon.GetInstance();
 }