2020 - Display how many days have passed
The Issue
The simulation doesn't record the number of days passed.
The Solution
Create a variable in the simulation class called 'days'. Increment 'days' every time the simulation processes a day. Final display the value on the main menu.
Example
find the simulation class, look for this:
class Simulation
{
private static Random rnd = new Random();
protected Settlement simulationSettlement;
protected int noOfCompanies;
protected double fuelCostPerUnit, baseCostForDelivery;
protected List<Company> companies = new List<Company>();
Now add a new variable:
public int days=0;
Now find the 'ProcessDayEnd' method in the simulation class. In the method you will see the final two lines of code is:
DisplayCompaniesAtDayEnd();
DisplayEventsAtDayEnd();
Before these two lines add:
days++;
Console.WriteLine("Days Passed: " + days);
You could also write this in the main menu, find the 'DisplayMenu' method in the simulation class:
Edit it to also do these 'Console.WriteLine' commands first:
<syntaxhighlight lang=csharp>
Console.WriteLine("\n*********************************");
Console.WriteLine("Days Passed: " + days);
Console.WriteLine("\n*********************************");