Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ##15. Разработать классы «точка» и «отрезок в пространстве». Члены-данные сделать закрытой частью в каждом классе. Для каждого класса
- ##разработать: конструктор с параметрами для инициализации, методы ввода/вывода. Разработать 2 функции сдвига отрезка в пространстве в
- ##заданную точку: метод класса и функцию с двумя параметрами (точка и отрезок).
- class Point():
- def __init__(self, x, y, z):
- self.__x = x
- self.__y = y
- self.__z = z
- def p_input(self):
- self.__x = float(input())
- self.__y = float(input())
- self.__z = float(input())
- def p_output(self):
- print("(", self.__x, ",", self.__y, ",", self.__z, ")", sep="")
- class Line():
- def __init__(self, x1, y1, z1, x2, y2, z2):
- self.__p1 = Point(x1, y1, z1)
- self.__p2 = Point(x2, y2, z2)
- def l_input(self):
- self.__p1.p_input()
- self.__p2.p_input()
- def l_output(self):
- self.__p1.p_output()
- self.__p2.p_output()
- def l_move(self, P):
- x1 = self.__p1._Point__x
- y1 = self.__p1._Point__y
- z1 = self.__p1._Point__z
- x2 = self.__p2._Point__x
- y2 = self.__p2._Point__y
- z2 = self.__p2._Point__z
- x = P._Point__x
- y = P._Point__y
- z = P._Point__z
- self.__p1 = P
- self.__p2 = Point(x2-x1+x, y2-y1+y, z2-z1+z)
- def L_move(P, L):
- x1 = L._Line__p1._Point__x
- y1 = L._Line__p1._Point__y
- z1 = L._Line__p1._Point__z
- x2 = L._Line__p2._Point__x
- y2 = L._Line__p2._Point__y
- z2 = L._Line__p2._Point__z
- x = P._Point__x
- y = P._Point__y
- z = P._Point__z
- L._Line__p1 = P
- L._Line__p2 = Point(x2-x1+x, y2-y1+y, z2-z1+z)
- P = Point(0., 0., 0.)
- P.p_output()
- P.p_input()
- P.p_output()
- L = Line(0., 0., 0., 1., 1., 1.)
- L.l_output()
- L.l_input()
- L.l_output()
- L.l_move(P)
- L.l_output()
- L_move(Point(0., 0., 0.), L)
- L.l_output()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement