mirror of
https://github.com/igorsimdyanov/php8.git
synced 2025-07-25 17:13:08 +00:00
28 lines
458 B
PHP
28 lines
458 B
PHP
<?php
|
|
class Point
|
|
{
|
|
private $x;
|
|
private $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);
|
|
}
|
|
}
|