本文整理汇总了C#中Mathmagician.NaturalNumbers.GetSequence方法的典型用法代码示例。如果您正苦于以下问题:C# NaturalNumbers.GetSequence方法的具体用法?C# NaturalNumbers.GetSequence怎么用?C# NaturalNumbers.GetSequence使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mathmagician.NaturalNumbers
的用法示例。
在下文中一共展示了NaturalNumbers.GetSequence方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShouldProvideSameSequences
public void ShouldProvideSameSequences()
{
NaturalNumbers nats = new NaturalNumbers();
int input = 10;
int[] sequenceWithLength = nats.GetSequence(input);
int[] sequenceNoLength = nats.GetSequence();
CollectionAssert.AreEqual(sequenceNoLength, sequenceWithLength);
}
示例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);
}
示例3: 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();
}
示例4: 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);
}
示例5: 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);
}
示例6: 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);
}
示例7: 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();
}
示例8: 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();
}
示例9: 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();
}
示例10: ShouldProvideSameSequences
public void ShouldProvideSameSequences()
{
NaturalNumbers nats = new NaturalNumbers();
BigInteger input = 10;
BigInteger[] sequencenolength = nats.GetSequence();
BigInteger[] sequencewithlength = nats.GetSequence(input);
CollectionAssert.AreEqual(sequencenolength, sequencewithlength);
}
示例11: 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();
}
示例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 == "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();
}
示例13: 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();
}