private void CheckConfig() { if (FieldSize < 1) { throw new ArgumentException("Invalid field size"); } if (!ShipsInfo.Any()) { throw new ArgumentException("Field has no ships"); } foreach (var item in ShipsInfo) { if (item.Key > FieldSize) { throw new ArgumentException("Ship size " + item.Key.ToString() + " is too big"); } } foreach (var item in ShipsInfo) { if (item.Key < 1) { throw new ArgumentException("Invalid ship size " + item.Key.ToString()); } } }
protected override void Config() { ShipsInfo.Add(1, 4); ShipsInfo.Add(2, 3); ShipsInfo.Add(3, 2); ShipsInfo.Add(4, 1); }
protected override void Config() { FieldSize = 10; ShipsInfo.Add(1, 4); ShipsInfo.Add(2, 3); ShipsInfo.Add(3, 2); ShipsInfo.Add(4, 1); }
protected override void Config() { FieldSize = 10; ShipsInfo.Add(-1, 1); }
protected override void Config() { FieldSize = 5; ShipsInfo.Add(6, 1); }