Beispiel #1
0
        public Automaton(Size size, ICellLifeService cellLifeService, ILogger logger)
        {
            size.ThrowIfNull(nameof(size));
            if (size.Width < 5)
            {
                //throw new ArgumentOutOfRangeException(nameof(Size), size.Width, "Width of automaton should be more than 3");
                logger.Log($"{nameof(size.Width)} of automaton should be more than 5");
            }
            if (size.Height < 5)
            {
                //throw new ArgumentOutOfRangeException(nameof(Size), size.Height, "Height of automaton should be more than 3");
                logger.Log($"{nameof(size.Height)} of automaton should be more than 5");
            }

            cellLifeService.ThrowIfNull(nameof(cellLifeService));
            CellLifeService = cellLifeService;

            logger.ThrowIfNull(nameof(logger));
            _logger = logger;

            Size    = new Size(System.Math.Max(size.Width, 5), System.Math.Max(size.Height, 5));
            CellSet = new CellSet();
            Init();
        }
Beispiel #2
0
 /// <summary>
 /// Initialization of inner fields and properties.
 /// </summary>
 protected void Init()
 {
     CellSet.Init(Size);
     Count = 0;
     AgeStatistics.Init(Size.Height * Size.Width);
 }