File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -9,5 +9,6 @@ namespace CellSimulator.Interfaces
99 public interface ICellPrinter
1010 {
1111 void PrintCells ( IEnumerable < ICell > cellsToPrint ) ;
12+ void PrintCellCount ( IEnumerable < ICell > cellsToPrint ) ;
1213 }
1314}
Original file line number Diff line number Diff line change @@ -11,9 +11,9 @@ namespace CellSimulator.Logic
1111 public class CellOverseer : ICellOverseer
1212 {
1313 public List < ICell > CellList { get ; set ; } = new List < ICell > ( ) ;
14- private int internalIdCounter = 0 ;
14+ private int internalIdCounter ;
1515
16- private Random rand = new Random ( ) ;
16+ private readonly Random rand = new Random ( ) ;
1717
1818 public void AddCell ( )
1919 {
@@ -36,7 +36,7 @@ public void SimulateNext()
3636 {
3737 CellList . Remove ( cell ) ;
3838 }
39- else if ( cell . LastAction == Enums . CellActionEnum . SuccessSplit )
39+ else if ( cell . LastAction == Enums . CellActionEnum . SuccessSplit )
4040 {
4141 AddCell ( ) ;
4242 }
Original file line number Diff line number Diff line change @@ -13,25 +13,32 @@ namespace CellSimulator.Logic
1313 public class SimulationManager : ISimulationManager
1414 {
1515 private readonly ICellOverseer Overseer = new CellOverseer ( ) ;
16- private readonly ISaveLoadManager SaveLoadmanager = new SaveLoadManager ( ) ;
16+ private readonly ISaveLoadManager SaverLoader = new SaveLoadManager ( ) ;
1717 private readonly IUserActionManager InputManager = new ConsoleInputManager ( ) ;
1818 private readonly ICellPrinter OutputManager = new ConsoleCellPrinter ( ) ;
1919
20+ private bool ShowAllInfo = true ;
21+
2022 public void StartSimulation ( )
2123 {
2224 SetInitialPopulation ( ) ;
2325 while ( true )
2426 {
25- OutputManager . PrintCells ( Overseer . CellList ) ;
27+ if ( ShowAllInfo )
28+ {
29+ OutputManager . PrintCells ( Overseer . CellList ) ;
30+ }
31+ OutputManager . PrintCellCount ( Overseer . CellList ) ;
2632 switch ( InputManager . GetUserAction ( ) )
2733 {
2834 case UserActionEnum . LOAD :
29- Overseer . CellList = ( List < ICell > ) SaveLoadmanager . LoadFromFile ( InputManager . GetUserFileName ( ) ) ;
35+ Overseer . CellList = ( List < ICell > ) SaverLoader . LoadFromFile ( InputManager . GetUserFileName ( ) ) ;
3036 break ;
3137 case UserActionEnum . SAVE :
32- SaveLoadmanager . SaveToFile ( InputManager . GetUserFileName ( ) , Overseer . CellList ) ;
38+ SaverLoader . SaveToFile ( InputManager . GetUserFileName ( ) , Overseer . CellList ) ;
3339 break ;
3440 case UserActionEnum . SWITCHSHOWINFO :
41+ ShowAllInfo = ! ShowAllInfo ;
3542 break ;
3643 case UserActionEnum . INVALID :
3744 Overseer . SimulateNext ( ) ;
Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ public class Cell : ICell
3131 private const int FOOD_CONSUMED_PER_ACTION = 5 ;
3232 private const int ENERGY_CONSUMED_PER_ACTION = 5 ;
3333
34- private Random rand ;
34+ private readonly Random rand ;
3535
3636 public Cell ( int id = 0 , Random rand = null )
3737 {
Original file line number Diff line number Diff line change @@ -11,6 +11,11 @@ public class ConsoleCellPrinter : ICellPrinter
1111 {
1212 private const char VALUE_SEPARATION_VALUE = '|' ;
1313
14+ public void PrintCellCount ( IEnumerable < ICell > cellsToPrint )
15+ {
16+ Console . WriteLine ( $ "Total Cells Alive: { cellsToPrint . Count ( ) } ") ;
17+ }
18+
1419 public void PrintCells ( IEnumerable < ICell > cellsToPrint )
1520 {
1621 foreach ( ICell cell in cellsToPrint )
You can’t perform that action at this time.
0 commit comments