本文整理汇总了Python中rectangle.Rectangle.getLength方法的典型用法代码示例。如果您正苦于以下问题:Python Rectangle.getLength方法的具体用法?Python Rectangle.getLength怎么用?Python Rectangle.getLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rectangle.Rectangle
的用法示例。
在下文中一共展示了Rectangle.getLength方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from rectangle import Rectangle [as 别名]
# 或者: from rectangle.Rectangle import getLength [as 别名]
def main(x0, y0, x1, y1):
rect = Rectangle(int(x0), int(y0), int(x1), int(y1))
msg = 'For the rectangle with corners located at ('
msg += str(x0) + ', ' + str(y0) + ') and ('
msg += str(x1) + ', ' + str(y1) + '):\n'
print(msg)
msg = 'The length is ' + str(rect.getLength())
msg += ' and the height is ' + str(rect.getHeight()) + '.'
print(msg)
msg = 'The area is ' + str(rect.getArea()) + '.'
print(msg)
示例2: RectangleTest
# 需要导入模块: from rectangle import Rectangle [as 别名]
# 或者: from rectangle.Rectangle import getLength [as 别名]
class RectangleTest(TestCase):
def setUp(self):
self.rectangle = Rectangle(1, 2, 3, 4)
def test_getLength(self):
assert_equal(self.rectangle.getLength(), 2)
def test_getHeight(self):
assert_equal(self.rectangle.getHeight(), 2)
def test_getArea(self):
assert_equal(self.rectangle.getArea(), 4)
def test_move(self):
self.rectangle.move(4, 8)
self.test_getLength()
self.test_getHeight()
self.test_getArea()