当前位置: 首页>>代码示例>>C#>>正文


C# Mathmagician.NaturalNumbers类代码示例

本文整理汇总了C#中Mathmagician.NaturalNumbers的典型用法代码示例。如果您正苦于以下问题:C# NaturalNumbers类的具体用法?C# NaturalNumbers怎么用?C# NaturalNumbers使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


NaturalNumbers类属于Mathmagician命名空间,在下文中一共展示了NaturalNumbers类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ShouldPrintFirstNumber

 public void ShouldPrintFirstNumber()
 {
     NaturalNumbers nats = new NaturalNumbers(); //This is an instance
     int expected = 1;
     int actual = nats.GetFirst();
     Assert.AreEqual(expected, actual);
 }
开发者ID:britcorona,项目名称:mathmagician,代码行数:7,代码来源:NaturalNumbersTests.cs

示例2: ShouldPrintSequenceOfNumbers

 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);
 }
开发者ID:britcorona,项目名称:mathmagician,代码行数:7,代码来源:NaturalNumbersTests.cs

示例3: ShouldPrintFirstNumber

 public void ShouldPrintFirstNumber()
 {
     NaturalNumbers nats = new NaturalNumbers();
     BigInteger expected = 1;
     BigInteger actual = nats.GetFirst();
     Assert.AreEqual(expected, actual);
 }
开发者ID:NewEvolution,项目名称:mathmagician,代码行数:7,代码来源:NaturalNumbersTests.cs

示例4: Main

        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{
                Console.WriteLine("Nope! Do better next time.");
            }
            Console.WriteLine("Press any key to exit...");
            Console.ReadKey();
        }
开发者ID:juan-rod,项目名称:mathmagician,代码行数:30,代码来源:Program.cs

示例5: ShouldPrintNextNumberInput3

 public void ShouldPrintNextNumberInput3()
 {
     NaturalNumbers nats = new NaturalNumbers();
     int input = 3;
     int expected = 4;
     int actual = nats.GetNext(input);
     Assert.AreEqual(expected, actual);
 }
开发者ID:britcorona,项目名称:mathmagician,代码行数:8,代码来源:NaturalNumbersTests.cs

示例6: PrintSequenceOfNumbers

 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);
 }
开发者ID:britcorona,项目名称:mathmagician,代码行数:8,代码来源:NaturalNumbersTests.cs

示例7: ShouldProvideSameSequences

 public void ShouldProvideSameSequences()
 {
     NaturalNumbers nats = new NaturalNumbers();
     int input = 10;
     int[] sequenceWithLength = nats.GetSequence(input);
     int[] sequenceNoLength = nats.GetSequence();
     CollectionAssert.AreEqual(sequenceNoLength, sequenceWithLength);
 }
开发者ID:AustinScott3573,项目名称:mathmagician,代码行数:8,代码来源:NaturalNumbersTest.cs

示例8: ShouldPrintAVariableSequenceOfNumbers

 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);
 }
开发者ID:britcorona,项目名称:mathmagician,代码行数:8,代码来源:NaturalNumbersTests.cs

示例9: ShouldPrintFirstNumber

 public void ShouldPrintFirstNumber()
 {
     NaturalNumbers nats = new NaturalNumbers();
     int expected = 1;
     int actual = nats.GetFirst();
     //asserts can compare expected outputs vs actual outputs
     Assert.AreEqual(expected, actual);
 }
开发者ID:Jergron,项目名称:mathmagician,代码行数:8,代码来源:NaturalNumbersTests.cs

示例10: EnsureICanCreateClassInstance

 public void EnsureICanCreateClassInstance()
 {
     //create a new instance of a class
     NaturalNumbers nats = new NaturalNumbers();
     //make sure instance is properly created
     Assert.IsNotNull(nats);
     //Right click on Mathagician add Class.  Create new file named the class.  i.e.  NaturalNumbers.cs
 }
开发者ID:pmconnolly80,项目名称:mathmagician,代码行数:8,代码来源:NaturalNumbersTests.cs

示例11: ShouldPrintAVariableSequenceofNumbers

 public void ShouldPrintAVariableSequenceofNumbers()
 {
     NaturalNumbers nats = new NaturalNumbers();
     //Must create instance of the class before testing the class.
     int input = 8;
     int[] expected = new int[] { 1, 2, 3, 4, 5, 6, 7, 8 };
     int[] actual = nats.GetSequence(input);
     CollectionAssert.AreEqual(expected, actual);
 }
开发者ID:Shelleydaviswise,项目名称:mathmagician,代码行数:9,代码来源:NaturalNumbersTests.cs

示例12: Main

        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();
        }
开发者ID:tombler,项目名称:mathmagician,代码行数:56,代码来源:Program.cs

示例13: EnsureICanCreateClassInstance

        public void EnsureICanCreateClassInstance()
        {
            // Bootstrapping test because you have yet to create a class
            // Make sure the build workflow is consistent and works well
            NaturalNumbers nats = new NaturalNumbers();
            // When you write tests you can ignore red squiggly lines because the class doesn't exist yet

            // Every test has the form of setup then assert
            Assert.IsNotNull(nats);
        }
开发者ID:BrendonPierson,项目名称:mathmagician,代码行数:10,代码来源:NaturalNumbersTests.cs

示例14: EnsureICanCreateClassInstance

 public void EnsureICanCreateClassInstance()
 {
     NaturalNumbers nats = new NaturalNumbers();  // <---- Every test has a setup
     // Assert class verifies true/false
     Assert.IsNotNull(nats);     // <----- And then an Assert
 }
开发者ID:rachyllmorgan,项目名称:mathmagician,代码行数:6,代码来源:NaturalNumbersTest.cs

示例15: Main

 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();
 }
开发者ID:NewEvolution,项目名称:mathmagician,代码行数:65,代码来源:Program.cs


注:本文中的Mathmagician.NaturalNumbers类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。