コード例 #1
0
        public void QueenAttack_ForCoordinants_SeeCoordinants()
        {
            QueenAttack queen = new QueenAttack(8, 2);

            Assert.Equal(8, queen.GetX());
            Assert.Equal(2, queen.GetY());
        }
コード例 #2
0
        public void CanAttack_Diagonally_true()
        {
            QueenAttack queen = new QueenAttack(4, 4);

            Assert.Equal(true, queen.CanAttack(1, 1));
            Assert.Equal(true, queen.CanAttack(8, 8));
            Assert.Equal(true, queen.CanAttack(1, 7));
            Assert.Equal(true, queen.CanAttack(7, 1));
        }
コード例 #3
0
        public static void Main()
        {
            QueenAttack newAttack = new QueenAttack();

            newAttack.setCoords();
            int xQueen    = newAttack.getXQueen();
            int yQueen    = newAttack.getYQueen();
            int xOpponant = newAttack.getXOpponant();
            int yOpponant = newAttack.getYOpponant();

            newAttack.QueenAttackCheck(xQueen, yQueen, xOpponant, yOpponant);
        }
コード例 #4
0
        public HomeModule()
        {
            Get["/"] = _ => {
                return(View["queen.cshtml", "Tell me where your queen is"]);
            };

            Get["/queen/{x}/{y}"] = parameters => {
                string      output      = "Choose a square to attack.";
                QueenAttack queenAttack = new QueenAttack(parameters.x, parameters.y);
                queenAttack.message = output;
                return(View["canattack.cshtml", queenAttack]);
            };

            Get["/attack/{x}/{y}"] = parameters => {
                string      output             = "Cannot attack!";
                QueenAttack currentQueenAttack = QueenAttack.GetQueen();
                if (currentQueenAttack.CanAttack(parameters.x, parameters.y))
                {
                    output = "Take the piece!";
                }
                currentQueenAttack.message = output;
                return(View["canattack.cshtml", currentQueenAttack]);
            };
        }
コード例 #5
0
        public void CanAttack_Vertically_true()
        {
            QueenAttack queen = new QueenAttack(8, 2);

            Assert.Equal(true, queen.CanAttack(7, 2));
        }
コード例 #6
0
        public void CanAttack_Horizontally_true()
        {
            QueenAttack queen = new QueenAttack(8, 2);

            Assert.Equal(true, queen.CanAttack(8, 3));
        }