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

Version Path
trackler-2.0.8.14 tracks/csharp/exercises/queen-attack/Example.cs
trackler-2.0.8.13 tracks/csharp/exercises/queen-attack/Example.cs
trackler-2.0.8.12 tracks/csharp/exercises/queen-attack/Example.cs
trackler-2.0.8.11 tracks/csharp/exercises/queen-attack/Example.cs
trackler-2.0.8.10 tracks/csharp/exercises/queen-attack/Example.cs
trackler-2.0.8.9 tracks/csharp/exercises/queen-attack/Example.cs
trackler-2.0.8.8 tracks/csharp/exercises/queen-attack/Example.cs
trackler-2.0.8.7 tracks/csharp/exercises/queen-attack/Example.cs
trackler-2.0.8.6 tracks/csharp/exercises/queen-attack/Example.cs
trackler-2.0.8.5 tracks/csharp/exercises/queen-attack/Example.cs
trackler-2.0.8.4 tracks/csharp/exercises/queen-attack/Example.cs
trackler-2.0.8.3 tracks/csharp/exercises/queen-attack/Example.cs
trackler-2.0.8.2 tracks/csharp/exercises/queen-attack/Example.cs
trackler-2.0.8.1 tracks/csharp/exercises/queen-attack/Example.cs
trackler-2.0.7.0 tracks/csharp/exercises/queen-attack/Example.cs
trackler-2.0.6.44 tracks/csharp/exercises/queen-attack/Example.cs
trackler-2.0.6.43 tracks/csharp/exercises/queen-attack/Example.cs
trackler-2.0.6.42 tracks/csharp/exercises/queen-attack/Example.cs
trackler-2.0.6.41 tracks/csharp/exercises/queen-attack/Example.cs
trackler-2.0.6.40 tracks/csharp/exercises/queen-attack/Example.cs