aboutsummaryrefslogtreecommitdiff
path: root/DotnetPgn/Models/Square.cs
blob: a3910d38fe64f3a49981361783e4fa9ddade382f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
using System;

namespace DotnetPgn.Models
{
    public record Square
    {
        public char Rank { get; }
        public int File { get; }

        public Square(char rank, int file)
        {
            if (rank < 'a' || rank > 'h')
                throw new ArgumentException($"Invalid rank '{rank}'.");

            if (file < 1 || file > 8)
                throw new ArgumentException($"Invalid file '{file}'.");

            Rank = rank;
            File = file;
        }
    }
}