public void shouldPrintFirstNumber()
 {
     NaturalNumbers nats = new NaturalNumbers();
     int expected = 1;
     int actual = nats.GetFirst();
     Assert.AreEqual(expected, actual);
 }
 public void shouldPrintSequenceOfNumbers()
 {
     NaturalNumbers nats = new NaturalNumbers();
     int[] expected = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
     int[] actual = nats.GetSequence();
     CollectionAssert.AreEqual(expected, actual);
 }
 public void shouldPrintNextNumberInput3()
 {
     NaturalNumbers nats = new NaturalNumbers();
     int input = 3;
     int expected = 4;
     int actual = nats.GetNext(input);
     Assert.AreEqual(expected, actual);
 }
 public void shouldPrintAVariableSequenceOfNumbers()
 {
     NaturalNumbers nats = new NaturalNumbers();
     int input = 8;
     int[] expected = new int[] { 1, 2, 3, 4, 5, 6, 7, 8 };
     int[] actual = nats.GetSequence(input);
     CollectionAssert.AreEqual(expected, actual);
 }
 public void printSequenceOfNumbers()
 {
     NaturalNumbers nats = new NaturalNumbers();
     int length = 7;
     string expected = "1 2 3 4 5 6 7";
     string actual = nats.ToString(nats.GetSequence(length));
     Assert.AreEqual(expected, actual);
 }
 public void ShouldProvideSameSequences()
 {
     NaturalNumbers nats = new NaturalNumbers();
     int input = 10;
     int[] sequenceWithLength = nats.GetSequence(input);
     int[] sequenceNoLength = nats.GetSequence();
     CollectionAssert.AreEqual(sequenceNoLength, sequenceWithLength);
 }
 public void EnsureICanCreateClassInstance()
 {
     NaturalNumbers nats = new NaturalNumbers();
     Assert.IsNotNull(nats);
 }
Beispiel #8
0
 static void Main(string[] args)
 {
     string prompt = "1.) Natural Numbers\n2.) Even Numbers\n3.) Odd Numbers\n4.) Prime Numbers\n5.) Fibonacci Numbers\n";
     Console.Write("What do you want me to do? \n");
     Console.Write(prompt);
     string response = Console.ReadLine();
     if (response == "1")
     {   //Natty
         Console.WriteLine("How many?");
         //Console.WriteLine(prompt);
         int length;
         string response_length = Console.ReadLine();
         bool parsed = int.TryParse(response_length, out length);
         if (parsed)
         {
           NaturalNumbers nats = new NaturalNumbers();
           Console.WriteLine(nats.ToString(nats.GetSequence(length)));
         }
     }
     else if (response == "2")
     {   //Even
         Console.WriteLine("How many?");
         //Console.WriteLine(prompt);
         int length;
         string response_length = Console.ReadLine();
         bool parsed = int.TryParse(response_length, out length);
         if (parsed)
         {
             EvenNumbers Even = new EvenNumbers();
             Console.WriteLine(Even.ToString(Even.GetSequence(length)));
         }
     }
     else if (response == "3")
     {   //Odd
         Console.WriteLine("How many?");
         //Console.WriteLine(prompt);
         int length;
         string response_length = Console.ReadLine();
         bool parsed = int.TryParse(response_length, out length);
         if (parsed)
         {
             OddNumbers Odd = new OddNumbers();
             Console.WriteLine(Odd.ToString(Odd.GetSequence(length)));
         }
     }
     else if (response == "4")
     {   //Prime
         Console.WriteLine("How many?");
         //Console.WriteLine(prompt);
         int length;
         string response_length = Console.ReadLine();
         bool parsed = int.TryParse(response_length, out length);
         if (parsed)
         {
             PrimeNumbers primes = new PrimeNumbers();
             Console.WriteLine(primes.ToString(primes.GetSequence(length)));
         }
     }
     else if (response == "5")
     {   //Fib
         Console.WriteLine("How many?");
         //Console.WriteLine(prompt);
         int length;
         string response_length = Console.ReadLine();
         bool parsed = int.TryParse(response_length, out length);
         if (parsed)
         {
             FibNumbers fibs = new FibNumbers();
             Console.WriteLine(fibs.ToString(fibs.GetSequence(length)));
         }
      }
      else
      {
         Console.WriteLine("Whoops! Try a number next time.");
      }
     Console.WriteLine("Press any key to exit");
     Console.ReadKey();
 }