Sha256: 17b237ea89f5890974c23de786d13f26a1d0ec4625e01e171926d962a4799370
Contents?: true
Size: 1 KB
Versions: 154
Compression:
Stored size: 1 KB
Contents
using System; public class Queen { public Queen(int row, int column) { Row = row; Column = column; } public int Row { get; } public int Column { get; } } public static class QueenAttack { public static bool CanAttack(Queen white, Queen black) { if (white.Row == black.Row && white.Column == black.Column) { throw new ArgumentException("The queens cannot be positioned at the same place."); } return black.Row == white.Row || black.Column == white.Column || Math.Abs(black.Row - white.Row) == Math.Abs(black.Column - white.Column); } public static Queen Create(int row, int column) { const int MIN_VALUE = 0; const int MAX_VALUE = 7; if (row < MIN_VALUE || column < MIN_VALUE || row > MAX_VALUE || column > MAX_VALUE) { throw new ArgumentOutOfRangeException("invalid queen position"); } return new Queen(row, column); } }
Version data entries
154 entries across 154 versions & 1 rubygems