Skip to content

Instantly share code, notes, and snippets.

@jianghu52
Created June 10, 2014 05:17
Show Gist options
  • Save jianghu52/a524f05e955c57e92bf9 to your computer and use it in GitHub Desktop.
Save jianghu52/a524f05e955c57e92bf9 to your computer and use it in GitHub Desktop.
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