Exemplo n.º 1
0
        /// <summary>
        /// Write 1- 100 Nmbers
        /// Replace *3 multiples  with : Support
        /// Repplavce *5 multiples  with : Training
        /// Relace both *3 & *5 multiples : SupportTraining 
        /// </summary>
        public void FindDivider()
        {
            PrintOutputToConsole objPrintOutputToConsole = new PrintOutputToConsole();

            for (int i = 1; i < 101; i++)
            {
                if (i % 3 == 0 && i % 5 == 0)
                {
                    objPrintOutputToConsole.UpdateConsle(Constants.SupportTraining);
                }
                else if (i % 3 == 0)
                {
                    objPrintOutputToConsole.UpdateConsle(Constants.Support);
                }

                else if (i % 5 == 0)
                {
                    objPrintOutputToConsole.UpdateConsle(Constants.Training);
                }
                else
                {
                    objPrintOutputToConsole.UpdateConsle(i.ToString());
                }
            }
        }
 /// <summary>
 /// Metod runs until user Enter correct Secret Number : 42
 /// if user enter 42 --> Print Corrent and close the Aplication
 /// </summary>
 public void GessSecretNumber()
 {
     PrintOutputToConsole objPrintOutputToConsole = new PrintOutputToConsole();
     SecretNmber42 objScretNmber42 = new SecretNmber42();
     string line;
     objPrintOutputToConsole.UpdateConsle(Constants.WELCOME_ADVICE);
     objPrintOutputToConsole.UpdateConsle(string.Empty);
     do
     {
         line = Console.ReadLine();
         int number;
         if (Int32.TryParse(line, out number))
         {
             if (objScretNmber42.EvalateSecretNumber(number))
             {
                 objPrintOutputToConsole.UpdateConsle(Constants.NUMBER_RECEIVED, number, Constants.CORRECT);
                 Environment.Exit(0);
             }
             else
             {
                 objPrintOutputToConsole.UpdateConsle(Constants.NUMBER_RECEIVED, number, Constants.INCORRECT);
             }
         }
         else
         {
             objPrintOutputToConsole.UpdateConsle(Constants.ERROR_MESSAGE);
         }
     } while (line != null);
 }