Skip to content

Added realisation#47

Open
IgnatSergeev wants to merge 1 commit intomainfrom
exam
Open

Added realisation#47
IgnatSergeev wants to merge 1 commit intomainfrom
exam

Conversation

@IgnatSergeev
Copy link
Owner

No description provided.

Comment on lines +9 to +10
}
public GameCore(int fieldSize)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}
public GameCore(int fieldSize)
}
public GameCore(int fieldSize)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Решение не собирается
  2. Есть warning от nullability-анализа
  3. Нет формы и логики с обработчиками элементов управления


private void RandomiseField()
{
var cellValues = new List<int>(Enumerable.Range(0, _dimensionSize * _dimensionSize / 2));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тут стоило исключение другого типа выбросить. Попадание в default statement этого оператора switch не зависит от аргумента метода

return _isOpened[firstIndex][secondIndex];
}

public bool OpenCell(int index)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Метод публичный, в него могут передать отрицательный или другой индекс, который вы бы посчитали некорректным. Нужно такие случаи обрабатывать

Comment on lines +77 to +78
int rowIndex = index % _dimensionSize;
var currentCell = (rowIndex, index - rowIndex * _dimensionSize);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Отображение из числа в пару у вас написано неправильно :)

Comment on lines +11 to +13
if (args.Length != 1)
{
Console.WriteLine("Incorrect number of program args");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Мы уже давно не печатаем в консоль в случае некорректного ввода :) В таких случаях нужно выкинуть исключение

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants