Skip to content

Commit 6f00b65

Browse files
committed
Finally using the SimulationManager in the Program.cs, Changed Output to actually be separate strings, Set Default-Values of Food, MaxFoox, Energy and MaxFood to 100 for Cell
1 parent c94da17 commit 6f00b65

5 files changed

Lines changed: 22 additions & 14 deletions

File tree

CellSimulator/Interfaces/ICellOverseer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace CellSimulator.Interfaces
88
{
99
public interface ICellOverseer
1010
{
11-
List<ICell> CellList { get; }
11+
List<ICell> CellList { get; set; }
1212

1313
void AddCell();
1414
void AddCell(ICell cell);

CellSimulator/Logic/SimulationManager.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,23 @@
66
using CellSimulator.Interfaces;
77
using CellSimulator.Input;
88
using CellSimulator.Enums;
9+
using CellSimulator.Output;
910

1011
namespace CellSimulator.Logic
1112
{
1213
public class SimulationManager : ISimulationManager
1314
{
14-
private readonly CellOverseer Overseer = new CellOverseer();
15-
private readonly SaveLoadManager SaveLoadmanager = new SaveLoadManager();
16-
private readonly ConsoleInputManager InputManager = new ConsoleInputManager();
15+
private readonly ICellOverseer Overseer = new CellOverseer();
16+
private readonly ISaveLoadManager SaveLoadmanager = new SaveLoadManager();
17+
private readonly IUserActionManager InputManager = new ConsoleInputManager();
18+
private readonly ICellPrinter OutputManager = new ConsoleCellPrinter();
1719

1820
public void StartSimulation()
1921
{
2022
SetInitialPopulation();
2123
while (true)
2224
{
25+
OutputManager.PrintCells(Overseer.CellList);
2326
switch (InputManager.GetUserAction())
2427
{
2528
case UserActionEnum.LOAD:
@@ -40,7 +43,7 @@ public void StartSimulation()
4043
private void SetInitialPopulation()
4144
{
4245
int cellCount = GetStartingCellCount();
43-
for(int i = 0; i < cellCount; ++i)
46+
for (int i = 0; i < cellCount; ++i)
4447
{
4548
Overseer.AddCell();
4649
}

CellSimulator/Models/Cell.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ public class Cell : ICell
1212
{
1313
public int ID { get; set; }
1414
public int Age { get; set; }
15-
public int Food { get; set; }
16-
public int MaxFood { get; set; }
17-
public int Energy { get; set; }
18-
public int MaxEnergy { get; set; }
15+
public int Food { get; set; } = 100;
16+
public int MaxFood { get; set; } = 100;
17+
public int Energy { get; set; } = 100;
18+
public int MaxEnergy { get; set; } = 100;
1919
public CellActionEnum LastAction { get; set; }
2020
public bool IsAlive { get; set; } = true;
2121

CellSimulator/Output/ConsoleCellPrinter.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ public void PrintCells(IEnumerable<ICell> cellsToPrint)
1717
{
1818
Console.WriteLine(string.Join(VALUE_SEPARATION_VALUE.ToString(),
1919
new string[] {
20-
$"{nameof(cell.ID)}:{cell.ID}" +
21-
$"{nameof(cell.Age)}:{cell.Age}" +
22-
$"{nameof(cell.Food)}:{cell.Food}" +
23-
$"{nameof(cell.Energy)}:{cell.Energy}" +
24-
$"{nameof(cell.LastAction)}:{cell.LastAction}"
20+
$"{nameof(cell.ID)}:{cell.ID}",
21+
$"{nameof(cell.Age)}:{cell.Age}",
22+
$"{nameof(cell.Food)}:{cell.Food}",
23+
$"{nameof(cell.Energy)}:{cell.Energy}",
24+
$"{nameof(cell.LastAction)}:{cell.LastAction}",
2525
}));
2626
}
2727
}

CellSimulator/Program.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,18 @@
33
using System.Linq;
44
using System.Text;
55
using System.Threading.Tasks;
6+
using CellSimulator.Logic;
67

78
namespace CellSimulator
89
{
910
class Program
1011
{
1112
static void Main(string[] args)
1213
{
14+
SimulationManager manager = new SimulationManager();
15+
manager.StartSimulation();
16+
return;
17+
1318
bool showCellInfo = true;
1419
CellOverseer overseer = new CellOverseer(1);
1520
while (true)

0 commit comments

Comments
 (0)