mirror of
https://github.com/igorsimdyanov/php8.git
synced 2025-08-03 16:43:03 +00:00
33 lines
573 B
PHP
33 lines
573 B
PHP
<?php
|
|
class Point {
|
|
private $x;
|
|
private $y;
|
|
|
|
public function __construct(int $x = 0, int $y = 0)
|
|
{
|
|
$this->x = $x;
|
|
$this->y = $y;
|
|
}
|
|
|
|
public function setX(int $x) : void
|
|
{
|
|
$this->x = $x;
|
|
}
|
|
public function setY(int $y) : void
|
|
{
|
|
$this->y = $y;
|
|
}
|
|
public function getX() : int
|
|
{
|
|
return $this->x;
|
|
}
|
|
public function getY() : int
|
|
{
|
|
return $this->y;
|
|
}
|
|
public function distance() : float
|
|
{
|
|
return sqrt($this->getX() ** 2 + $this->getY() ** 2);
|
|
}
|
|
}
|