/
Punto.php
65 lines (55 loc) · 999 Bytes
/
Punto.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
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
/**
* Created by PhpStorm.
* User: Jordi
* Date: 30/09/2015
* Time: 15:40
*/
namespace Figura;
class Punto
{
private $x;
private $y;
//En PHP solo puede haver un constructor
function __construct($X, $Y)
{
$this->x = $X;
$this->y = $Y;
}
/**
* @param $X
* @return mixed
* ------------------------------Setters y getters
*/
function setX($X){
$this->x=$X;
}
function getX(){
return $this->x;
}
/**
* @return mixed
*/
public function getY()
{
return $this->y;
}
/**
* @param mixed $y
*/
public function setY($y)
{
$this->y = $y;
}
function desplazar($dx, $dy){
$this->x=$this->x+$dx;
$this->y=$this->y+$dy;
}
function distancia(Punto $P){
$dx=$this->x-$P->getX();
$dy=$this->y-$P->getY();
}
function __toString(){
return "X=".$this->x.", Y=".$this->y;
}
}