/
Spinogryz
/
pythonObject
Обзор
Документация
Войти
/
Spinogryz
/
pythonObject
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
point.py
39 строк
1 KB
Spinogryz
privat_methods
15 фев 2025, 22:40
15 фев 2025, 22:40
da6276b
Код
Авторство
О чём код?
class Point: def __init__(self, x, y, units): self.x = x self.y = y self.__units = units def get_units(self): return self.__units def set_units(self, units): self.__units = units def distance_to(self, point): return ((self.x - point.x)**2 + (self.y - point.y)**2)**0.5 def __str__(self): str_repr = 'Point({0:.5f}, {1:.5f})'.format(self.x, self.y) return str_repr def hello(self): return 'Hello! My coords are: {0:.5f}, {1:.5f}. Nice to meet you!'.format(self.x, self.y) class Point3D(Point): def __init__(self, x, y, z, units): Point.__init__(self, x, y, units) self.z = z def distance3d_to(self, point): return ((self.x - point.x)**2 + (self.y - point.y)**2 + (self.z - point.z)**2)**0.5 def __str__(self): str_repr = 'Point({0:.5f}, {1:.5f}, {2:.5f})'.format(self.x, self.y, self.z) return str_repr def hello(self): return 'Hello! My coords are: {0:.5f}, {1:.5f}, {2:.5f}. Nice to meet you!'.format(self.x, self.y, self.z)