Sha256: c0801ccdbf2b2fa90fc9a0e830bb97a1876c23fad64038a6fcbc68a7ffedcd2c
Contents?: true
Size: 804 Bytes
Versions: 115
Compression:
Stored size: 804 Bytes
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 class Queens { private readonly Queen _white; private readonly Queen _black; public Queens(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."); } _black = black; _white = white; } public bool CanAttack() { return _black.Row == _white.Row || _black.Column == _white.Column || Math.Abs(_black.Row - _white.Row) == Math.Abs(_black.Column - _white.Column); } }
Version data entries
115 entries across 115 versions & 1 rubygems