Created
June 10, 2014 05:17
-
-
Save jianghu52/a524f05e955c57e92bf9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Point: | |
def __init__(self, x=0, y=0): | |
self.x = x | |
self.y = y | |
a = Point(1, 4) | |
b = Point(4, 4) | |
c = Point(1, 2) | |
d = Point(4, 2) | |
class Rectangle: | |
def __init__(self, a, b, c, d): | |
self.a = a | |
self.b = b | |
self.c = c | |
self.d = d | |
def area(self): | |
hei = a.y - c.y | |
len = b.x - a.x | |
return len * hei | |
r = Rectangle(a, b, c, d) | |
print r.area() | |
a.x = 10 | |
print r.area() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment