Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            CounterModel      counter           = new CounterModel();
            CounterController counterController = new CounterController();

            Counter_0_0_Sould_be_Love_All(counter, counterController);
            Counter_3_3_Sould_be_Deuce(counter, counterController);
            Console.Write("\nTest Done.\n");
            Console.ReadLine();
        }
Ejemplo n.º 2
0
        static void Counter_0_0_Sould_be_Love_All(CounterModel counter, CounterController counterController)
        {
            counterController.ResetCounter(counter);
            string result = counterController.Score(counter);

            if (result != "Love All")
            {
                Console.Write($"0:0 |Test Error : {result} should be Love All");
            }
        }
Ejemplo n.º 3
0
 public bool isMatchEnd(CounterModel counterModel)
 {
     if (counterModel.PlayerOneScore >= 4 && counterModel.PlayerOneScore - counterModel.PlayerTwoScore >= 2)
     {
         return(true);
     }
     if (counterModel.PlayerTwoScore >= 4 && counterModel.PlayerTwoScore - counterModel.PlayerOneScore >= 2)
     {
         return(true);
     }
     return(false);
 }
Ejemplo n.º 4
0
        static void Counter_3_3_Sould_be_Deuce(CounterModel counter, CounterController counterController)
        {
            counterController.ResetCounter(counter);
            counterController.FirstPlayerScore(counter);
            counterController.SecondPlayerScore(counter);
            counterController.FirstPlayerScore(counter);
            counterController.SecondPlayerScore(counter);
            counterController.FirstPlayerScore(counter);
            counterController.SecondPlayerScore(counter);
            string result = counterController.Score(counter);

            if (result != "Deuce")
            {
                Console.Write($"3:3 | Test Error : {result} should be Deuce");
            }
        }
Ejemplo n.º 5
0
 public string Score(CounterModel counterModel)
 {
     String[] dict = new string[] { "Love", "Fifteen", "Thirty", "Forty" };
     if (counterModel.PlayerOneScore == counterModel.PlayerTwoScore)
     {
         if (counterModel.PlayerOneScore >= 3)
         {
             return("Deuce");
         }
         return(dict[counterModel.PlayerOneScore] + " All");
     }
     else
     {
         if (counterModel.PlayerOneScore < 4 && counterModel.PlayerTwoScore < 4)
         {
             return(dict[counterModel.PlayerOneScore] + " " + dict[counterModel.PlayerTwoScore]);
         }
         else
         {
             if (Math.Abs(counterModel.PlayerOneScore - counterModel.PlayerTwoScore) < 2)
             {
                 if (counterModel.PlayerOneScore > counterModel.PlayerTwoScore)
                 {
                     return("PlayerA Adv");
                 }
                 else
                 {
                     return("Player2 Adv");
                 }
             }
             else
             {
                 if (counterModel.PlayerOneScore > counterModel.PlayerTwoScore)
                 {
                     return("PlayerA Won");
                 }
                 else
                 {
                     return("Player2 Won");
                 }
             }
         }
     }
 }
Ejemplo n.º 6
0
 public void ResetCounter(CounterModel counterModel)
 {
     counterModel.PlayerOneScore = 0;
     counterModel.PlayerTwoScore = 0;
 }