-
Notifications
You must be signed in to change notification settings - Fork 0
/
CircleAndCircle_handler.php
52 lines (48 loc) · 1.59 KB
/
CircleAndCircle_handler.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
/**
* Created by PhpStorm.
* User: dobrodeev
* Date: 14.08.2018
* Time: 12:13
*/
require_once 'CircleAndCircle.php';
spl_autoload_register(function ($className)
{
include $className.'.php';
});
if (isset($_POST['go']))
{
if (($_POST['circle1']['x1']) && ($_POST['circle1']['y1']) && $_POST['circle1']['r1'] &&
($_POST['circle2']['x2']) && ($_POST['circle2']['y2']) && $_POST['circle2']['r2'])
{
if ($_POST['circle1']['r1'] > 0 && $_POST['circle2']['r2'] > 0)
{
/**
echo '<pre>';
print_r($_POST);
echo '</pre>';
*/
$x1 = $_POST['circle1']['x1'];
$y1 = $_POST['circle1']['y1'];
$r1 = $_POST['circle1']['r1'];
$x2 = $_POST['circle2']['x2'];
$y2 = $_POST['circle2']['y2'];
$r2 = $_POST['circle2']['r2'];
$circleObject1 = new CircleAndCircleClass($x1, $y1, $r1);
// $circleObject1->setCircle($x1, $y1, $r1);
$circleObject2 = new CircleAndCircleClass($x2, $y2, $r2);
// $circleObject2->setCircle($x2, $y2, $r2);
echo '<span style="color: blue">Всего точек пересечения: '.$circleObject1->countIntersections($circleObject2).'</span><br>';
}
else
{
$result = 'Введите корректныые радиусы. <br>';
echo "<span style='color:red;'>$result</span>";
}
}
else
{
$result = 'Введите все данные.<br>';
echo '<span style="color: red">'.$result.'<span>';
}
}