Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Point {
- private $x;
- private $y;
- private $z;
- public function __construct(int $x, int $y, int $z) {
- $this->x = $x;
- $this->y = $y;
- $this->z = $z;
- }
- public function distance(Point $point):float {
- return sqrt(
- pow($point->x - $this->x, 2) +
- pow($point->y - $this->y, 2) +
- pow($point->z - $this->z, 2));
- }
- }
- $pointA = new Point(0, -3, 3);
- $pointB = new Point(3, 1, 3);
- echo $pointA->distance($pointB);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement