Simulation - AS 2017

From TRCCompSci - AQA Computer Science
Jump to: navigation, search

The Code

private static void Simulation()
{
    int YearsToRun;
    char[,] Field = new char[FIELDLENGTH, FIELDWIDTH];
    bool Continuing;
    int Year;
    string Response;
    YearsToRun = GetHowLongToRun();
    if (YearsToRun != 0)
    {
        InitialiseField(Field);
        if (YearsToRun >= 1)
        {
            for (Year = 1; Year <= YearsToRun; Year++)
            {
                SimulateOneYear(Field, Year);
            }
        }
        else
        {
            Continuing = true;
            Year = 0;
            while (Continuing)
            {
                Year++;
                SimulateOneYear(Field, Year);
                Console.Write("Press Enter to run simulation for another Year, Input X to stop: ");
                Response = Console.ReadLine();
                if (Response == "x" || Response == "X")
                {
                    Continuing = false;
                }
            }
        }
        Console.WriteLine("End of Simulation");
    }
    Console.ReadLine();
}

Explanation