Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """Class Point"""
- check_num= lambda num : isinstance(num,(int,float))
- class Point:
- def __init__(self,x,y):
- if check_num(x)==False:
- raise ValueError("x must be an intger/float")
- if check_num(y)==False:
- raise ValueError("y must be an intger/float")
- self.__x = x
- self.__y = y
- """setters"""
- def set_x(self,x):
- if check_num(x)==False:
- raise ValueError("x must be an intger/float")
- self.__x = x
- def set_y(self,y):
- if check_num(y)==False:
- raise ValueError("y must be an intger/float")
- self.__y = y
- """getters"""
- def get_x(self):
- return self.__x
- def get_y(self):
- return self.__y
- """str method"""
- def __str__(self):
- return "("+'%.2f' % self.__x +","+ '%.2f' % self.__y+")"
- a=5
- b=Point(52,321.11)
- """Class Line"""
- is_point = lambda point : isinstance(point,(Point))
- class Line:
- def __init__(self,p,q):
- if is_point(q)==False:
- raise Exception("your Value must be Point type.")
- if is_point(p)==False:
- raise Exception("your Value must be Point type.")
- self.__p = p
- self.__q = q
- """setters"""
- def set_q(self,q):
- if is_point(q)==False:
- raise Exception("your Value must be Point type.")
- self.__q = q
- def set_p(self,p):
- if is_point(p)==False:
- raise Exception("your Value must be Point type.")
- self.__p = p
- """getters"""
- def get_q(self):
- return self.__q
- def get_p(self):
- return self.__p
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement