public CrosswordSolver(int[][] topNumbers, int[][] leftNumbers) { TopNumbers = topNumbers; LeftNumbers = leftNumbers; Width = topNumbers.GetLength(0); Height = leftNumbers.GetLength(0); Cages = new CageType[Height, Width]; Methods = new List <Func <CageType[], int[], CageType[]> >(); InitializeMethods(); }
public bool AddToCage(BaseDinosaur dinoPatate) { if (!isFull) { if (type == CageType.CageEmpty) { type = (CageType)dinoPatate.Type; dinosaurs.Capacity = SetCapacity(); } dinosaurs.Add(dinoPatate); return(true); } return(false); }
public Cage(CageType cageType, double square, byte capacity) : base() { try { if (square <= 0 || capacity == 0) { throw new ArgumentException("Недопустимые значения площади и/или емкости!!!"); } _cageType = cageType; _square = square; this.Capacity = capacity; } catch (ArgumentException) { throw; } }
public void ApplyMethodForRow(int rowIndex, Func <CageType[], int[], CageType[]> method) { CageType[] row = new CageType[Width]; for (int i = 0; i < Width; i++) { row[i] = Cages[rowIndex, i]; } if (row.All(w => w != CageType.White)) { return; } row = ApplyMethodForLine(row, LeftNumbers[rowIndex], method); for (int i = 0; i < Width; i++) { Cages[rowIndex, i] = row[i]; } }
public void ApplyMethodForColumn(int columnIndex, Func <CageType[], int[], CageType[]> method) { CageType[] column = new CageType[Height]; for (int i = 0; i < Height; i++) { column[i] = Cages[i, columnIndex]; } if (column.All(w => w != CageType.White)) { return; } column = ApplyMethodForLine(column, TopNumbers[columnIndex], method); for (int i = 0; i < Height; i++) { Cages[i, columnIndex] = column[i]; } }
public Cage(CageType cageType) : base() { _cageType = cageType; switch (cageType) { case CageType.WithTrees: _square = 15.00; this.Capacity = 10; break; case CageType.WithRocks: _square = 15.00; this.Capacity = 5; break; case CageType.WithWater: _square = 20.00; this.Capacity = 10; break; } }
// Самый простой метод считает справа и слева числа и заполняет public CageType[] Method0001(CageType[] cages, int[] numbers) { CageType[] oldCages = new CageType[cages.Length]; Array.Copy(cages, oldCages, cages.Length); if (numbers.Length == 1 && (cages.Length < numbers[0])) { CompareCages(oldCages, cages, "1", numbers); return(cages); } var l = numbers.Sum() + numbers.Length - 1; var L = cages.Length; var n = L - l; int counter = 0; foreach (var number in numbers) { if (number > n) { int skipedIndex = counter + n; if (skipedIndex < 0) { CompareCages(oldCages, cages, "1", numbers); return(cages); } for (int i = 0; i >= 0 && i < number - n; i++) { cages[skipedIndex] = CageType.Black; skipedIndex++; } } counter += (1 + number); } CompareCages(oldCages, cages, "1", numbers); return(cages); }
public Ape(string type, string name, CageType cageType) { Type = type; Name = name; CageType = cageType; }
public Cage(CageType type) { Type = type; }