25 lines
632 B
C#
25 lines
632 B
C#
namespace Snake.Core;
|
|
|
|
public sealed class Board
|
|
{
|
|
public Board(int width, int height)
|
|
{
|
|
if (width < 2)
|
|
throw new ArgumentOutOfRangeException(nameof(width), "Width must be at least 2.");
|
|
|
|
if (height < 2)
|
|
throw new ArgumentOutOfRangeException(nameof(height), "Height must be at least 2.");
|
|
|
|
Width = width;
|
|
Height = height;
|
|
}
|
|
|
|
public int Width { get; }
|
|
|
|
public int Height { get; }
|
|
|
|
public bool IsWithinBounds(Position position) =>
|
|
position.X >= 0 && position.X < Width &&
|
|
position.Y >= 0 && position.Y < Height;
|
|
}
|