Skip to content

Instantly share code, notes, and snippets.

@barnash
Created December 17, 2013 06:30
Show Gist options
  • Save barnash/8000919 to your computer and use it in GitHub Desktop.
Save barnash/8000919 to your computer and use it in GitHub Desktop.
קוד מתרגול 7
class Point:
""" this point is...
bnla ba lba
"""
def __init__(self, x = 0, y = 0):
self.x = x
self.y = y
def __repr__(self):
return "(" + str(self.x) + "," + str(self.y) + ")"
def is_origin(self):
return self.x == 0 and self.y == 0
def __eq__(self, other):
if isinstance(other, tuple):
return self.x == other[0] and self.y == other[1]
else:
assert isinstance(other, Point)
return self.x == other.x and self.y == other.y
def add(self, other):
assert isinstance(other, Point)
return Point(self.x + other.x, self.y + other.y)
def __add__(self, other):
return self.add(other)
def __lt__(self, other):
assert isinstance(other, Point)
return self.x < other.x and self.y < other.y
def get_x(self):
return self.x
def get_y(self):
return self.y
def set_x(self, x):
self.x = x
def set_y(self, y):
self.y = y
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment