本文整理汇总了C#中Mathmagician.NaturalNumbers类的典型用法代码示例。如果您正苦于以下问题:C# NaturalNumbers类的具体用法?C# NaturalNumbers怎么用?C# NaturalNumbers使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NaturalNumbers类属于Mathmagician命名空间,在下文中一共展示了NaturalNumbers类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: 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!");
}
}
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();
}
开发者ID:taylormiley,项目名称:mathmagician,代码行数:98,代码来源:Program.cs
示例17: 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 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();
}
开发者ID:Shelleydaviswise,项目名称:mathmagician,代码行数:65,代码来源:Program.cs
示例18: ShouldProvideSameSequences
public void ShouldProvideSameSequences()
{
NaturalNumbers nats = new NaturalNumbers();
BigInteger input = 10;
BigInteger[] sequencenolength = nats.GetSequence();
BigInteger[] sequencewithlength = nats.GetSequence(input);
CollectionAssert.AreEqual(sequencenolength, sequencewithlength);
}
开发者ID:NewEvolution,项目名称:mathmagician,代码行数:8,代码来源:NaturalNumbersTests.cs
示例19: Main
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();
}
开发者ID:gregkorte,项目名称:Cohort10,代码行数:82,代码来源:Program.cs
示例20: Main
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();
}
开发者ID:danielcossins,项目名称:mathmagician,代码行数:63,代码来源:Program.cs
注:本文中的Mathmagician.NaturalNumbers类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论