Skip to content

Commit 9a82a25

Browse files
committed
Changed if-else to switch
1 parent 9387e09 commit 9a82a25

1 file changed

Lines changed: 18 additions & 19 deletions

File tree

Program.cs

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,28 +23,27 @@ static void Main(string[] args)
2323
}
2424
Console.WriteLine("ALIVE:" + overseer.cells.Count());
2525
string commandEntered = Console.ReadLine().ToLower();
26-
if (commandEntered != "")
26+
if (!string.IsNullOrEmpty(commandEntered))
2727
{
28-
if (commandEntered == "save")
28+
switch (commandEntered)
2929
{
30-
overseer.SaveToFile();
31-
continue;
32-
}
33-
else if (commandEntered == "load")
34-
{
35-
string fileName = Console.ReadLine();
36-
if (fileName == "")
37-
{
30+
case "save":
31+
overseer.SaveToFile();
3832
continue;
39-
}
40-
else
41-
{
42-
overseer.LoadFromFile(fileName);
43-
}
44-
}
45-
else if (commandEntered == "switchshowinfo")
46-
{
47-
showCellInfo = !showCellInfo;
33+
case "load":
34+
string fileName = Console.ReadLine();
35+
if (fileName == "")
36+
{
37+
continue;
38+
}
39+
else
40+
{
41+
overseer.LoadFromFile(fileName);
42+
}
43+
break;
44+
case "switchshowinfo":
45+
showCellInfo = !showCellInfo;
46+
break;
4847
}
4948
}
5049

0 commit comments

Comments
 (0)