Ejemplo n.º 1
0
 public void OddShouldPrintSequenceOfNumbers()
 {
     OddNumbers odd = new OddNumbers();
     int[] expected = new int[] { 1, 3, 5, 7, 9, 11, 13, 15, 17, 19 };
     int[] actual = odd.GetSequence();
     CollectionAssert.AreEqual(expected, actual);
 }
Ejemplo n.º 2
0
 public void OddPrintSequenceOfNumbers()
 {
     OddNumbers odd = new OddNumbers();
     int length = 7;
     string expected = "1 3 5 7 9 11 13";
     string actual = odd.ToString(odd.GetSequence(length));
     Assert.AreEqual(expected, actual);
 }
Ejemplo n.º 3
0
 public void OddShouldPrintAVariableSequenceOfNumbers()
 {
     OddNumbers odd = new OddNumbers();
     int input = 8;
     int[] expected = new int[] { 1, 3, 5, 7, 9, 11, 13, 15 };
     int[] actual = odd.GetSequence(input);
     CollectionAssert.AreEqual(expected, actual);
 }
Ejemplo n.º 4
0
 public void OddShouldPrintAVariableSequenceofNumbers()
 {
     OddNumbers odd = new OddNumbers();
     //Must create instance of the class before testing the class.
     int input = 8;
     int[] expected = new int[] { 1, 3, 5, 7, 9, 11, 13, 15 };
     int[] actual = odd.GetSequence(input);
     CollectionAssert.AreEqual(expected, actual);
 }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            string prompt = "> ";
            Console.WriteLine("What do you want me to do?");
            Console.Write(prompt);
            string response = Console.ReadLine();
            if (response.ToLower().Contains("numbers"))
            {
                Console.WriteLine("How many?");
                Console.Write(prompt);
                int length;
                string response_length = Console.ReadLine();
                bool parsed = int.TryParse(response_length, out length);
                if (parsed && Convert.ToInt32(response_length) < 1000)
                {
                    if (response.ToLower().Equals("natural numbers"))
                    {
                        NaturalNumbers nats = new NaturalNumbers();
                        Console.WriteLine(nats.ToString(nats.GetSequence(length)));
                    }
                    else if (response.ToLower().Equals("even numbers"))
                    {
                        EvenNumbers even = new EvenNumbers();
                        Console.WriteLine(even.ToString(even.GetSequence(length)));
                    }
                    else if (response.ToLower().Equals("odd numbers"))
                    {
                        OddNumbers odd = new OddNumbers();
                        Console.WriteLine(odd.ToString(odd.GetSequence(length)));
                    }
                    else if (response.ToLower().Equals("fibonacci numbers"))
                    {
                        Fibonacci fib = new Fibonacci();
                        Console.WriteLine(fib.ToString(fib.GetSequence(length)));
                    }
                    else if (response.ToLower().Equals("prime numbers"))
                    {
                        PrimeNumbers prime = new PrimeNumbers();
                        Console.WriteLine(prime.ToString(prime.GetSequence(length)));
                    }
                    else
                    {
                        Console.WriteLine("Whoops!");
                    }

                }
                else {
                    Console.WriteLine("Whoops!");
                }
            }
            else {
                Console.WriteLine("Nope! Do better next time.");
            }
            Console.WriteLine("Press any key to exit.");
            Console.ReadKey();
        }
Ejemplo n.º 6
0
 static void Main(string[] args)
 {
     string prompt = "> ";
     string splash = @"         ,/   *
       _,'/_   |
       `("")' ,'/
        _ _,-M-./ /
        \_\_\.   /    __  __       _   _                           _      _
      )"" |  (    |  \/  | __ _| |_| |__  _ __ ___   __ _  __ _(_) ___(_) __ _ _ __
       __/   M   \__ | |\/| |/ _` | __| '_ \| '_ ` _ \ / _` |/ _` | |/ __| |/ _` | '_ \
       \    /|\    / | |  | | (_| | |_| | | | | | | | | (_| | (_| | | (__| | (_| | | | |
        `--'|||`--'  |_|  |_|\__,_|\__|_| |_|_| |_| |_|\__,_|\__, |_|\___|_|\__,_|_| |_|
       ==^==                                             |___/";
     Console.WriteLine(splash);
     Console.WriteLine("What do you want me to do?");
     Console.Write(prompt);
     string[] valid_responses = new string[] { "natural numbers", "even numbers", "odd numbers", "fibonacci numbers", "prime numbers"};
     string response = Console.ReadLine().ToLower();
     if (valid_responses.Contains(response))
     {
         Console.WriteLine("How many?");
         Console.Write(prompt);
         string response_length = Console.ReadLine();
         int length;
         bool parsed = int.TryParse(response_length, out length);
         if (parsed)
         {
             if (response == "natural numbers")
             {
                 NaturalNumbers nats = new NaturalNumbers();
                 Console.WriteLine(nats.ToString(nats.GetSequence(length)));
             }
             if (response == "even numbers")
             {
                 EvenNumbers even = new EvenNumbers();
                 Console.WriteLine(even.ToString(even.GetSequence(length)));
             }
             if (response == "odd numbers")
             {
                 OddNumbers odd = new OddNumbers();
                 Console.WriteLine(odd.ToString(odd.GetSequence(length)));
             }
             if (response == "fibonacci numbers")
             {
                 FibonacciNumbers fibonacci = new FibonacciNumbers();
                 Console.WriteLine(fibonacci.ToString(fibonacci.GetSequence(length)));
             }
             if (response == "prime numbers")
             {
                 PrimeNumbers prime = new PrimeNumbers();
                 Console.WriteLine(prime.ToString(prime.GetSequence(length)));
             }
         }
         else
         {
             Console.WriteLine("Whoops!");
         }
     }
     else
     {
         Console.WriteLine("Nope! Do better next time.");
     }
     Console.Write("Press any key to exit...");
     Console.ReadKey();
 }
Ejemplo n.º 7
0
 static void Main(string[] args)
 {
     string prompt = "> ";
                                                             // cw tab tab (console.writeline stub)
     Console.WriteLine("What do you want me to do?");        // WriteLine gets new line
     Console.Write(prompt);                                  // Write keeps on same line
     string response = Console.ReadLine();
     if (response == "natural numbers")
     {
         Console.WriteLine("How much you wan?");
         Console.Write(prompt);
         string response_length = Console.ReadLine();
         int length;
         bool parsed = int.TryParse(response_length, out length);
         if (parsed)
         {
             NaturalNumbers nats = new NaturalNumbers();
             Console.WriteLine(nats.ToString(nats.GetSequence(length)));
         }
         else
         {
             Console.WriteLine("Whoops!");
         }
     }
     else if (response == "odd numbers")
     {
         Console.WriteLine("How much you wan?");
         Console.WriteLine(prompt);
         string response_length = Console.ReadLine();
         int length;
         bool parsed = int.TryParse(response_length, out length);
         if (parsed)
         {
             OddNumbers odd = new OddNumbers();
             Console.WriteLine(odd.ToString(odd.GetSequence(length)));
         }
         else
         {
             Console.WriteLine("Whoops!");
         }
     }
     else if (response == "even numbers")
     {
         Console.WriteLine("How much you wan?");
         Console.WriteLine(prompt);
         string response_length = Console.ReadLine();
         int length;
         bool parsed = int.TryParse(response_length, out length);
         if (parsed)
         {
             EvenNumbers even = new EvenNumbers();
             Console.WriteLine(even.ToString(even.GetSequence(length)));
         }
         else
         {
             Console.WriteLine("Whoops!");
         }
     }
     else if (response == "fibonacci sequence")
     {
         Console.WriteLine("How much you wan?");
         Console.WriteLine(prompt);
         string response_length = Console.ReadLine();
         int length;
         bool parsed = int.TryParse(response_length, out length);
         if (parsed)
         {
             FibonacciNumbers fib = new FibonacciNumbers();
             Console.WriteLine(fib.ToString(fib.GetSequence(length)));
         }
         else
         {
             Console.WriteLine("Whoops!");
         }
     }
     else
     {
         Console.WriteLine("Nope! Do better next time.");
     }
     Console.WriteLine("Press any key to exit...");
     Console.ReadKey();
 }
Ejemplo n.º 8
0
        static void Main(string[] args)
        {
            string prompt = ">";
            Console.WriteLine("What do you want me to do?");
            Console.Write(prompt);
            string response = Console.ReadLine();
            if (response == "natural numbers")
            {
                Console.WriteLine("How Many?");
                Console.Write(prompt);
                string response_length = Console.ReadLine();
                int length;
                bool parsed = int.TryParse(response_length, out length);
                if (parsed)
                {
                    NaturalNumbers nats = new NaturalNumbers();
                    Console.WriteLine(nats.ToString(nats.GetSequence(length)));
                }
                    else
                {
                    Console.WriteLine("Whoops!");
                };
            }
            else if (response == "even numbers")
            {
                Console.WriteLine("How Many?");
                Console.Write(prompt);
                string response_length = Console.ReadLine();
                int length;
                bool parsed = int.TryParse(response_length, out length);
                if (parsed)
                {
                    EvenNumbers even = new EvenNumbers();
                    Console.WriteLine(even.ToString(even.GetSequence(length)));
                }
                else
                {
                    Console.WriteLine("Whoops!");
                };
            }
            else if (response == "odd numbers")
            {
                Console.WriteLine("How Many?");
                Console.Write(prompt);
                string response_length = Console.ReadLine();
                int length;
                bool parsed = int.TryParse(response_length, out length);
                if (parsed)
                {
                    OddNumbers odd = new OddNumbers();
                    Console.WriteLine(odd.ToString(odd.GetSequence(length)));
                }
                else
                {
                    Console.WriteLine("Whoops!");
                };
            }

            else
            {
                Console.WriteLine("Nope! Do better next time!");
            }
            Console.WriteLine("Press Any Key to Exit");
            Console.ReadKey();
        }
Ejemplo n.º 9
0
        static void Main(string[] args)
        {
            string prompt = "> ";
            Console.WriteLine("What do you want me to do?");
            Console.Write(prompt);
            string response = Console.ReadLine();
            if (response == "natural numbers")
            {
                Console.WriteLine("How many?");
                Console.Write(prompt);
                string response_length = Console.ReadLine();
                int length;
                bool parsed = int.TryParse(response_length, out length);
                if (parsed)
                {
                    NaturalNumbers nats = new NaturalNumbers();
                    Console.WriteLine(nats.ToString(nats.GetSequence(length)));
                }
                else
                {
                    Console.WriteLine("Whoops!");
                }

            }
            if (response == "even numbers") {
                Console.WriteLine("How many?");
                Console.Write(prompt);
                string response_length = Console.ReadLine();
                int length;
                bool parsed = int.TryParse(response_length, out length);
                if (parsed)
                {
                    EvenNumbers even = new EvenNumbers();
                    Console.WriteLine(even.ToString(even.GetSequence(length)));
                }
                else
                {
                    Console.WriteLine("Whoops!");
                }
            }
            if (response == "odd numbers")
            {
                Console.WriteLine("How many?");
                Console.Write(prompt);
                string response_length = Console.ReadLine();
                int length;
                bool parsed = int.TryParse(response_length, out length);
                if (parsed)
                {
                    OddNumbers odd = new OddNumbers();
                    Console.WriteLine(odd.ToString(odd.GetSequence(length)));
                }
                else
                {
                    Console.WriteLine("Whoops!");
                }
            }
            if (response == "fibonacci numbers")
            {
                Console.WriteLine("How many?");
                Console.Write(prompt);
                string response_length = Console.ReadLine();
                int length;
                bool parsed = int.TryParse(response_length, out length);
                if (parsed)
                {
                    FibonacciNumbers fibonacci = new FibonacciNumbers();
                    Console.WriteLine(fibonacci.ToString(fibonacci.GetSequence(length)));
                }
                else
                {
                    Console.WriteLine("Whoops!");
                }
            }
            if (response == "prime numbers")
            {
                Console.WriteLine("How many?");
                Console.Write(prompt);
                string response_length = Console.ReadLine();
                int length;
                bool parsed = int.TryParse(response_length, out length);
                if (parsed)
                {
                    PrimeNumbers prime = new PrimeNumbers();
                    Console.WriteLine(prime.ToString(prime.GetSequence(length)));
                }
                else
                {
                    Console.WriteLine("Whoops!");
                }
            }
            else
            {
                Console.WriteLine("Nope! Do better next time.");
            }
            Console.WriteLine("Press any key to exit...");
            Console.ReadKey();
        }
Ejemplo n.º 10
0
 static void Main(string[] args)
 {
     string prompt = "> ";
     Console.WriteLine(@"What do you want me to do?
     Natural Numers
     Even Numbers
     Odd Numbers
     Fibonacci Numbers
     Prime Numbers");
     Console.Write(prompt);
     string input = getValidstring();
     Console.WriteLine("How many?");
     int inputInt = getValidInt();
     //if (response.ToLower() == "natural numbers")
     //{
     //    Console.WriteLine("How many?");
     //    Console.Write(prompt);
     //    string response_length = Console.ReadLine();
     //    int length;
     //    bool parsed = int.TryParse(response_length, out length);
     //    if (parsed)
     //    {
     //        NaturalNumbers nats = new NaturalNumbers();
     //        Console.WriteLine(nats.ToString(nats.GetSequence(length)));
     //    }
     //    else
     //    {
     //        Console.WriteLine("Whoops!");
     //    }
     //}
     //else
     //{
     //    Console.WriteLine("Nope! Do better next time.");
     //}
     switch (input.ToLower())
     {
         case "natural numbers":
             NaturalNumbers nats = new NaturalNumbers();
             Console.WriteLine(nats.ToString(nats.GetSequence(inputInt)));
             break;
         case "even numbers":
             EvenNumbers evens = new EvenNumbers();
             Console.WriteLine(evens.ToString(evens.GetSequence(inputInt)));
             break;
         case "odd numbers":
             OddNumbers odds = new OddNumbers();
             Console.WriteLine(odds.ToString(odds.GetSequence(inputInt)));
             break;
         case "fibonacci numbers":
             FibonacciNumbers fibs = new FibonacciNumbers();
             Console.WriteLine(fibs.ToString(fibs.GetSequence(inputInt)));
             break;
         case "prime numbers":
             PrimeNumbers primes = new PrimeNumbers();
             Console.WriteLine(primes.ToString(primes.GetSequence(inputInt)));
             break;
         default:
             Console.WriteLine("Whoops!");
             break;
     }
     Console.WriteLine("Press any key to finish . . .");
     Console.ReadKey();
 }