コード例 #1
0
 public void FibonacciShouldPrintFirstNumber()
 {
     FibonacciNumbers fibonacci = new FibonacciNumbers();
     int expected = 1;
     int actual = fibonacci.GetFirst();
     Assert.AreEqual(expected, actual);
 }
コード例 #2
0
 public void FibonacciShouldPrintNextNumber()
 {
     FibonacciNumbers fibonacci = new FibonacciNumbers();
     int input = 1;
     int expected = 1;
     int actual = fibonacci.GetNext(input);
     Assert.AreEqual(expected, actual);
 }
コード例 #3
0
 public void FibonacciShouldPrintNextNumber()
 {
     FibonacciNumbers fibonacci = new FibonacciNumbers();
     BigInteger input = fibonacci.GetFirst();
     BigInteger expected = 1;
     BigInteger actual = fibonacci.GetNext(input);
     Assert.AreEqual(expected, actual);
 }
コード例 #4
0
 public void FibonacciShouldPrintAVariableSequenceOfNumbers()
 {
     FibonacciNumbers nats = new FibonacciNumbers();
     int input = 8;
     int[] expected = new int[] { 1, 1, 2, 3, 5, 8, 13, 21 };
     int[] actual = nats.GetSequence(input);
     CollectionAssert.AreEqual(expected, actual);
 }
コード例 #5
0
 public void FibonacciShouldPrintVariableSequenceOfNumbers()
 {
     FibonacciNumbers fibonacci = new FibonacciNumbers();
     BigInteger input = 8;
     BigInteger[] expected = new BigInteger[] { 1, 1, 2, 3, 5, 8, 13, 21 };
     BigInteger[] actual = fibonacci.GetSequence(input);
     CollectionAssert.AreEqual(expected, actual);
 }
コード例 #6
0
 public void FibonacciPrintOfSequenceOfNumbers()
 {
     FibonacciNumbers fibonacci = new FibonacciNumbers();
     int length = 8;
     string expected = "1 1 2 3 5 8 13 21";
     string actual = fibonacci.ToString(fibonacci.GetSequence(length));
     Assert.AreEqual(expected, actual);
 }
コード例 #7
0
 public void FibonacciPrintSequencenumbers()
 {
     FibonacciNumbers fib = new FibonacciNumbers();
     int length = 7;
     string expected = "1 1 2 3 5 8 13";
     string actual = fib.ToString(fib.GetSequence(length));
     Assert.AreEqual(expected, actual);
 }
コード例 #8
0
 public void FibonacciShouldPrintAVariableSequenceofNumbers()
 {
     FibonacciNumbers fib = new FibonacciNumbers();
     //Must create instance of the class before testing the class.
     int input = 8;
     int[] expected = new int[] { 1, 1, 2, 3, 5, 8, 13, 21};
     int[] actual = fib.GetSequence(input);
     CollectionAssert.AreEqual(expected, actual);
 }
コード例 #9
0
 public void FibonacciShouldPrintAVariableSequenceOfNumbers()
 {
     FibonacciNumbers fib = new FibonacciNumbers();
     int input = 8;
     int[] expected = new int[] { 0, 1, 1, 2, 3, 5, 8, 13 };
     int[] actual = fib.GetSequence(input);
     //Collection Assert compares collections
     CollectionAssert.AreEqual(expected, actual);
 }
コード例 #10
0
ファイル: FibonacciTests.cs プロジェクト: gregkorte/Cohort10
 public void FibonacciShouldPrintNextNumber()
 {
     FibonacciNumbers fib = new FibonacciNumbers();
     int[] array = new int[] { 0, 1, 1, 2, 3, 5 };
     int input = array.Last();
     int expected = 8;
     int actual = // fib.GetNextFib(input);
         input + array.ElementAt(array.Length - 2);
     Assert.AreEqual(expected, actual);
 }
コード例 #11
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.Equals("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.Equals("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.Equals("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 if (response.Equals("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!");
                }

            }
            else if (response.Equals("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 primes = new PrimeNumbers();
                    Console.WriteLine(primes.ToString(primes.GetSequence(length)));
                }
                else
                {
                    Console.WriteLine("Whoops!");
                }

            }
            else
            {
                Console.WriteLine("Nope! Do better next time.");
            }
            Console.WriteLine("Press any key to exit..");
            Console.ReadKey();
        }
コード例 #12
0
ファイル: Program.cs プロジェクト: danielcossins/mathmagician
 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();
 }
コード例 #13
0
 public void FibonacciEnsuerICanCreateClassInstance()
 {
     FibonacciNumbers fibonacci = new FibonacciNumbers();
     Assert.IsNotNull(fibonacci);
 }
コード例 #14
0
 public void FibonacciEnsureICanCreateClassInstance()
 {
     FibonacciNumbers fib = new FibonacciNumbers();
     //Will have red lines during test writing. It's OK.
     Assert.IsNotNull(fib);
 }
コード例 #15
0
ファイル: Program.cs プロジェクト: NewEvolution/mathmagician
 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();
 }
コード例 #16
0
ファイル: Program.cs プロジェクト: gregkorte/Cohort10
 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();
 }
コード例 #17
0
 public void FibonnacoiEnsureICanCreateClassInstance()
 {
     FibonacciNumbers fib = new FibonacciNumbers();
     Assert.IsNotNull(fib);
 }