Conversation
| } | ||
| public GameCore(int fieldSize) |
There was a problem hiding this comment.
| } | |
| public GameCore(int fieldSize) | |
| } | |
| public GameCore(int fieldSize) |
There was a problem hiding this comment.
- Решение не собирается
- Есть warning от nullability-анализа
- Нет формы и логики с обработчиками элементов управления
|
|
||
| private void RandomiseField() | ||
| { | ||
| var cellValues = new List<int>(Enumerable.Range(0, _dimensionSize * _dimensionSize / 2)); |
There was a problem hiding this comment.
| var cellValues = new List<int>(Enumerable.Range(0, _dimensionSize * _dimensionSize / 2)); | |
| var cellValues = new List<int>(Enumerable.Range(0, _dimensionSize * _dimensionSize / 2 - 1)); |
Более того, _dimensionSize * _dimensionSize / 2 - 1 стоило вынести в отдельную переменную, несколько раз это выражение в методе используется
| _lastOpened = (firstIndex, index - firstIndex * _dimensionSize); | ||
| return true; | ||
| default: | ||
| throw new ArgumentOutOfRangeException(nameof(_state)); |
There was a problem hiding this comment.
Тут стоило исключение другого типа выбросить. Попадание в default statement этого оператора switch не зависит от аргумента метода
| return _isOpened[firstIndex][secondIndex]; | ||
| } | ||
|
|
||
| public bool OpenCell(int index) |
There was a problem hiding this comment.
Метод публичный, в него могут передать отрицательный или другой индекс, который вы бы посчитали некорректным. Нужно такие случаи обрабатывать
| int rowIndex = index % _dimensionSize; | ||
| var currentCell = (rowIndex, index - rowIndex * _dimensionSize); |
There was a problem hiding this comment.
Отображение из числа в пару у вас написано неправильно :)
| if (args.Length != 1) | ||
| { | ||
| Console.WriteLine("Incorrect number of program args"); |
There was a problem hiding this comment.
Мы уже давно не печатаем в консоль в случае некорректного ввода :) В таких случаях нужно выкинуть исключение
No description provided.