【发布时间】:2012-04-16 01:40:51
【问题描述】:
class Rectangle(object):
def __init__(self, (top left corner), width, height):
"""
__init__(self, (x, y), integer, integer)
"""
self._x = x
self._y = y
self._width = width
self._height = height
def get_bottom_right(self):
x + self.width = d
y + self.height = t
return '' + d,t
所以我想为一个矩形创建一个类,我想找到矩形的右下角。通过将高度和宽度添加到左上角可以找到矩形的右下角。例如。 (2,3),4,7 将使底角为 (6,10)。但是,我不相信我的代码是正确的。这是我第一次使用类,所以关于如何解释它的一些提示和技巧将非常有帮助。
【问题讨论】:
-
当你发布代码时,你可以确保它的格式正确,因为它在 python 中很重要。
-
抱歉,下次发帖时我会记住这一点。