-
Notifications
You must be signed in to change notification settings - Fork 90
Expand file tree
/
Copy pathejercicio2.py
More file actions
51 lines (39 loc) · 771 Bytes
/
ejercicio2.py
File metadata and controls
51 lines (39 loc) · 771 Bytes
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
class punto():
def __init__(self,x=0,y=0):
self.x=x
self.y=y
@property
def x(self):
return self._x
@x.setter
def x(self,x):
self._x=x
@property
def y(self):
return self._y
@y.setter
def y(self,y):
self._y=y
def __str__(self):
return "{0}:{1}".format(self.x,self.y)
def distancia(self,otro):
dx = self.x - otro.x
dy = self.y - otro.y
return (dx*dx + dy*dy)**0.5
class punto3d(punto):
def __init__(self,x=0,y=0,z=0):
super().__init__(x,y)
self.z=z
@property
def z(self):
return self._z
@z.setter
def z(self,z):
self._z=z
def __str__(self):
return super().__str__()+":"+str(self.z)
def distancia(self,otro):
dx = self.x - otro.x
dy = self.y - otro.y
dz = self.z - otro.z
return (dx*dx + dy*dy + dz*dz)**0.5