function test_diag()
 {
     //Arrange
     $test_Queen = new Queen();
     $pieceY = 5;
     $pieceX = 5;
     //Act
     $results = $test_Queen->makeQueenAttack($pieceX, $pieceY);
     //Assert
     $this->assertEquals(true, $results);
 }
 function test_canAttack_diagonal()
 {
     // arrange
     $test_Queen = new Queen(4, 4);
     // act
     $result = $test_Queen->canAttack(1, 1);
     $result2 = $test_Queen->canAttack(1, 3);
     // assert
     $this->assertEquals(true, $result);
     $this->assertEquals(false, $result2);
 }
Beispiel #3
0
 function test_canAttack_horizontalAttack()
 {
     //Arrange
     $test_Queen = new Queen();
     $input1 = 3;
     $input2 = 7;
     $input3 = 4;
     $input4 = 7;
     //Act
     $result = $test_Queen->canAttack($input1, $input2, $input3, $input4);
     //Assert
     $this->assertEquals(true, $result);
 }
Beispiel #4
0
<?php

require_once __DIR__ . "/../vendor/autoload.php";
require_once __DIR__ . "/../src/Queen.php";
$app = new Silex\Application();
$app['debug'] = TRUE;
$app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . '/../views'));
$app->get('/', function () use($app) {
    return $app['twig']->render('queen.html.twig');
});
$app->get('attack', function () use($app) {
    $my_Queen = new Queen($_GET['xq'], $_GET['yq']);
    $attack = $my_Queen->canAttack($_GET['xp'], $_GET['yp']);
    return $app['twig']->render('attack.html.twig', array('coordinates' => $attack));
    //do i need to be "rendering" an array here? is that what i'm sending to twig?
});
return $app;
Beispiel #5
0
<?php

/* 
互いに取り合えないように8個のクィーンを8x8のチェス盤に配置せよ
*/
require_once '../part/Queen.php';
$queen = new Queen();
$queen->set(0);
echo '答えは全部で' . $queen->getCount() . '個です。';
Beispiel #6
0
<?php

require_once __DIR__ . "/../vendor/autoload.php";
require_once __DIR__ . "/../src/Queen.php";
$app = new Silex\Application();
$app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . '/../views'));
$app->get("/", function () use($app) {
    return $app['twig']->render('index.html.twig');
});
$app->get("/queen_attack", function () use($app) {
    $my_Queen = new Queen($_GET['qx_coord'], $_GET['qy_coord']);
    $results = $my_Queen->canAttack($_GET['ix_coord'], $_GET['iy_coord']);
    return $app['twig']->render('index.html.twig', array('result' => $results));
});
return $app;
Beispiel #7
0
<?php

require_once __DIR__ . "/../vendor/autoload.php";
require_once __DIR__ . "/../src/Queen.php";
$app = new Silex\Application();
$app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . '/../views'));
$app->get("/", function () use($app) {
    return $app['twig']->render('form.html.twig');
});
$app->get("/view_attack", function () use($app) {
    $my_Queen = new Queen();
    $check_attack = $my_Queen->canAttack($_GET['queenx'], $_GET['queeny'], $_GET['kingx'], $_GET['kingy']);
    return $app['twig']->render('queen_attacked.html.twig', array('result' => $check_attack));
});
return $app;