Skip to content

Commit 9387e09

Browse files
committed
Added new supported Command
Added new Command to make it possible to show the info of each Cell or not
1 parent 60f8726 commit 9387e09

2 files changed

Lines changed: 15 additions & 7 deletions

File tree

.vs/CellSimulator/v15/.suo

4.5 KB
Binary file not shown.

Program.cs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,30 @@ class Program
1010
{
1111
static void Main(string[] args)
1212
{
13+
bool showCellInfo = true;
1314
CellOverseer overseer = new CellOverseer(1);
1415
while (true)
1516
{
16-
foreach(Cell cell in overseer.cells)
17+
if (showCellInfo)
1718
{
18-
Console.WriteLine("ID:" + cell.id + "|AGE:" + cell.age + "|FOOD:" + cell.food + "|ENERGY:" + cell.energy + "|ACTION:" + cell.lastAction);
19+
foreach (Cell cell in overseer.cells)
20+
{
21+
Console.WriteLine("ID:" + cell.id + "|AGE:" + cell.age + "|FOOD:" + cell.food + "|ENERGY:" + cell.energy + "|ACTION:" + cell.lastAction);
22+
}
1923
}
2024
Console.WriteLine("ALIVE:" + overseer.cells.Count());
21-
string keyPressed = Console.ReadLine();
22-
if(keyPressed != "")
25+
string commandEntered = Console.ReadLine().ToLower();
26+
if (commandEntered != "")
2327
{
24-
if(keyPressed == "save")
28+
if (commandEntered == "save")
2529
{
2630
overseer.SaveToFile();
2731
continue;
2832
}
29-
else if(keyPressed == "load")
33+
else if (commandEntered == "load")
3034
{
3135
string fileName = Console.ReadLine();
32-
if(fileName == "")
36+
if (fileName == "")
3337
{
3438
continue;
3539
}
@@ -38,6 +42,10 @@ static void Main(string[] args)
3842
overseer.LoadFromFile(fileName);
3943
}
4044
}
45+
else if (commandEntered == "switchshowinfo")
46+
{
47+
showCellInfo = !showCellInfo;
48+
}
4149
}
4250

4351
overseer.SimulateNext();

0 commit comments

Comments
 (0)