Difference between revisions of "Main Section"

From TRCCompSci - AQA Computer Science
Jump to: navigation, search
(Explanation)
(The Code)
Line 3: Line 3:
 
C#=
 
C#=
 
<syntaxhighlight lang="csharp" line>
 
<syntaxhighlight lang="csharp" line>
static void Main(string[] args)
+
/*static void Main(string[] args)
 
     {
 
     {
 
       Simulation Sim;
 
       Simulation Sim;
Line 48: Line 48:
 
       } while (MenuOption != 3);
 
       } while (MenuOption != 3);
 
       Console.ReadKey();
 
       Console.ReadKey();
    }
+
*/    }
 +
static void Main(string[] args)
 +
{
 +
  do
 +
  {
 +
      Console.WriteLine("rekt");
 +
  } while(true)
 +
}
 
</syntaxhighlight>
 
</syntaxhighlight>
 
|-|
 
|-|

Revision as of 11:10, 15 December 2016

The Code

 1 /*static void Main(string[] args)
 2     {
 3       Simulation Sim;
 4       int MenuOption;
 5       int LandscapeSize;
 6       int InitialWarrenCount;
 7       int InitialFoxCount;
 8       int Variability;
 9       bool FixedInitialLocations;
10       do
11       {
12         Console.WriteLine("Predator Prey Simulation Main Menu");
13         Console.WriteLine();
14         Console.WriteLine("1. Run simulation with default settings");
15         Console.WriteLine("2. Run simulation with custom settings");
16         Console.WriteLine("3. Exit");
17         Console.WriteLine();
18         Console.Write("Select option: ");
19         MenuOption = Convert.ToInt32(Console.ReadLine());
20         if ((MenuOption == 1) || (MenuOption == 2))
21         {
22           if (MenuOption == 1)
23           {
24             LandscapeSize = 15;
25             InitialWarrenCount = 5;
26             InitialFoxCount = 5;
27             Variability = 0;
28             FixedInitialLocations = true;
29           }
30           else
31           {
32             Console.Write("Landscape Size: ");
33             LandscapeSize = Convert.ToInt32(Console.ReadLine());
34             Console.Write("Initial number of warrens: ");
35             InitialWarrenCount = Convert.ToInt32(Console.ReadLine());
36             Console.Write("Initial number of foxes: ");
37             InitialFoxCount = Convert.ToInt32(Console.ReadLine());
38             Console.Write("Randomness variability (percent): ");
39             Variability = Convert.ToInt32(Console.ReadLine());
40             FixedInitialLocations = false;
41           }
42           Sim = new Simulation(LandscapeSize, InitialWarrenCount, InitialFoxCount, Variability, FixedInitialLocations);
43         }
44       } while (MenuOption != 3);
45       Console.ReadKey();
46 */    }
47 static void Main(string[] args)
48 {
49    do
50    {
51       Console.WriteLine("rekt");
52    } while(true)
53 }

Explanation

The main program declares an instance of the Simulation Class.


It declares variables for the key information required for the simulation.


The option is to start with the predefined values or to enter the values yourself. If option 1 is selected the variables will be assigned their default value, however if 2 is selected the values entered by the use will be assigned to the variables.


The instance of the Simulation Class will be assigned the values predefined or entered by the user. This will obviously start the simulation and run the code within that class.