The number of years should be between 0 and 5 but no validation takes place
Revision as of 13:59, 9 March 2017 by Sluttyruttybutty (talk | contribs) (Created page with "<syntaxhighlight lang=csharp line> static int GetHowLongToRun() { int Years = 0; Console.WriteLine("Welcome to the Plant Growing Simulation"); Console.Wr...")
1 static int GetHowLongToRun()
2 {
3 int Years = 0;
4 Console.WriteLine("Welcome to the Plant Growing Simulation");
5 Console.WriteLine();
6 Console.WriteLine("You can step through the simulation a year at a time");
7 Console.WriteLine("or run the simulation for 0 to 5 years");
8 Console.WriteLine("How many years do you want the simulation to run?");
9 Console.Write("Enter a number between 0 and 5, or -1 for stepping mode: ");
10
11 while(true)
12 {
13 Years = Convert.ToInt32(Console.ReadLine());
14
15 if (Years >= -1 && Years <= 5)
16 break;
17 else
18 Console.Write("You MUST Enter a number between 0 and 5, or -1 for stepping mode: ");
19 }
20
21 return Years;
22 }