예제 #1
0
 public Queens(Queen white, Queen black)
 {
     if (white.Equals(black))
     {
         throw new ArgumentException();
     }
     this.white = white;
     this.black = black;
 }
예제 #2
0
 public static void TestInequality_DifferentPieceAndPlayer()
 {
     Piece piece1 = new King(Player.White);
     Piece piece2 = new Queen(Player.Black);
     Assert.AreNotEqual(piece1, piece2, "piece1 and piece2 are equal");
     Assert.False(piece1.Equals(piece2), "piece1.Equals(piece2) should be false");
     Assert.False(piece2.Equals(piece1), "piece2.Equals(piece1) should be false");
     Assert.False(piece1 == piece2, "piece1 == piece2 should be false");
     Assert.False(piece2 == piece1, "piece2 == piece1 should be false");
     Assert.True(piece1 != piece2, "piece1 != piece2 should be True");
     Assert.True(piece2 != piece1, "piece2 != piece1 should be True");
     Assert.AreNotEqual(piece1.GetHashCode(), piece2.GetHashCode(), "Hash codes are equal");
 }
        public static void TestInequality_DifferentPieceAndPlayer()
        {
            Piece piece1 = new King(Player.White);
            Piece piece2 = new Queen(Player.Black);

            Assert.AreNotEqual(piece1, piece2, "piece1 and piece2 are equal");
            Assert.False(piece1.Equals(piece2), "piece1.Equals(piece2) should be false");
            Assert.False(piece2.Equals(piece1), "piece2.Equals(piece1) should be false");
            Assert.False(piece1 == piece2, "piece1 == piece2 should be false");
            Assert.False(piece2 == piece1, "piece2 == piece1 should be false");
            Assert.True(piece1 != piece2, "piece1 != piece2 should be True");
            Assert.True(piece2 != piece1, "piece2 != piece1 should be True");
            Assert.AreNotEqual(piece1.GetHashCode(), piece2.GetHashCode(), "Hash codes are equal");
        }
예제 #4
0
    public static bool CanAttack(Queen w, Queen b)

    {
        if (w.Equals(b))
        {
            throw new ArgumentException();
        }

        return(w.R == b.R ||

               w.C == b.C ||

               Math.Abs(w.R - b.R) == Math.Abs(w.C - b.C));
    }
예제 #5
0
        public static void TestInequality_DifferentPieceAndPlayer()
        {
            var piece1 = new King(Player.White);
            var piece2 = new Queen(Player.Black);

            Assert.AreNotEqual(piece1, piece2);
            Assert.False(piece1.Equals(piece2));
            Assert.False(piece2.Equals(piece1));
            Assert.False(piece1 == piece2);
            Assert.False(piece2 == piece1);
            Assert.True(piece1 != piece2);
            Assert.True(piece2 != piece1);
            Assert.AreNotEqual(piece1.GetHashCode(), piece2.GetHashCode());
        }