Advertisement
Guest User

Untitled

a guest
Mar 20th, 2018
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. from math import sqrt
  2.  
  3. class Punkt2D(object):
  4.   def __init__(self, x , y):
  5.     self.x = x
  6.     self.y = y
  7.  
  8.   def odl(self, other):
  9.     return sqrt(((other.x - self.x)*(other.x - self.x)+(other.y - self.y)*(other.y - self.y)))
  10.    
  11. class Punkt3D(Punkt2D):
  12.   def __init__(self, x, y, z):
  13.     super().__init__(x, y)
  14.     self.z = z
  15.    
  16.   def odl(self, other):
  17.     return sqrt(((other.x-self.x)*(other.x-self.x)+(other.y-self.y)*(other.y-self.y)+(other.z-self.z)*(other.z-self.z)))
  18.    
  19.    
  20. ob1 = Punkt2D(1, 1)
  21.  
  22. ob2 = Punkt2D(2, 2)
  23.  
  24. ob3 = Punkt3D(1, 1, 1)
  25.  
  26. ob4 = Punkt3D(3, 3, 3)
  27.  
  28. print(ob1.odl(ob2))
  29.  
  30. print(ob3.odl(ob4))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement