Example #1
0
 public function get_detail($id)
 {
     $figure = Figure::with('FigureDesc')->find($id);
     if (is_null($figure)) {
         return json_encode('Figure not found', 404);
     } else {
         return json_encode($figure);
     }
 }
Example #2
0
 public function __construct($shape)
 {
     parent::__construct($shape);
 }
Example #3
0
 public function __construct($x_center, $y_center, $color, $line_dim, $length)
 {
     parent::__construct('square', $x_center, $y_center, $color, $line_dim);
     $this->length = $length;
 }
Example #4
0
 function __construct($centerX, $centerY, $side)
 {
     parent::__construct($centerX, $centerY);
     $this->side = $side;
 }
Example #5
0
 /**
  * 
  * @param \Figure $figure Фигура вывода
  * @return string контент изображения
  */
 public function output(\Figure $figure)
 {
     return $figure->drawImage();
 }
Example #6
0
    }
    function square()
    {
        return 3.14 * 3.14 * $this->radius / 2;
    }
}
class Rectangle extends Figure
{
    private $a;
    private $b;
    function __construct($a, $b)
    {
        $this->a = (double) $a;
        $this->b = (double) $b;
        self::$sum += $this->square();
    }
    function square()
    {
        return $this->a * $this->b;
    }
}
$arr = array(new Circle(5), new Rectangle(39, 33), new Rectangle(21, 9), new Circle(11.4), new Rectangle(15, 2));
/*$square = 0;
foreach($arr as $obj){
	$obj->test(); die;
	// Полиморфизм!
	$square += $obj->square();
}*/
//echo "Общая площадь: {$square}";
echo "Общая площадь: " . Figure::getSum();
Example #7
0
<?php

//header("Content-Type: application/json");
require_once __DIR__ . "/Figure.php";
global $config;
$request = (object) $_REQUEST;
$post = json_decode(file_get_contents("php://input"));
$get = (object) $_GET;
if (!empty($request->method) || !empty($post->method)) {
    $fgr = new Figure();
    $method = empty($request->method) ? $post->method : $request->method;
    switch ($method) {
        case "saveF":
            $data = $fgr->saveFigureData($request->data, $request->type, $request->name);
            die(json_encode($data));
            break;
        case "getByName":
            $data = $fgr->getByNames($request->fileName);
            die(json_encode($data));
            break;
        default:
            die(json_encode(array('error' => "false request")));
            break;
    }
} else {
    die(json_encode(array('error' => "Empty request method!")));
}
Example #8
0
 function __construct($a, $b, $c, $p, $name)
 {
     $this->b = $b;
     $this->c = $c;
     parent::__construct($a, $p, $name);
 }
Example #9
0
 /**
  * 
  * @param \Figure $figure Фигура вывода
  * @return array массив точек
  */
 public function output(\Figure $figure)
 {
     return $figure->returnArray();
 }
Example #10
0
<?php

require_once __DIR__ . DIRECTORY_SEPARATOR . 'Autoloader.php';
Autoloader::register();
// Предположим получение входных данных и валидацию здесь
$name_figure = 'Rectangle';
$params = array();
$outpuer = 'Image';
$figure = \Figure::makeFigure($name_figure, $params);
\Outputer::createOutputer($outpuer)->output($figure);