我做这个练习。我得到了Line
和{def isonline
需要所有的属性x,y,a,b,c
。所以这就是我所做的。你觉得我该怎么解决这个问题吗?在
class Point:
def __init__(self,x,y):
self.x=x
self.y=y
class Line:
def __init__(self,a,b,c):
self.a=a
self.b=b
self.c=c
def slope(self):
try:
return -self.a/self.b
except ZeroDivisionError:
return None
def isonline(self,Point):
if (self.a*self.x+self.b*self.y+self.c)==0:
return True
else:
return False
coordinatesPoint=Point(4,1)
abcfromLine=Line(10,2,1)
print abcfromLine.slope()
print abcfromLine.isonline(coordinatesPoint)
我认为
Point.x
,Point.y
会解决你的问题。在顺便说一句,我更喜欢用小写字母作为参数。在
相关问题 更多 >
编程相关推荐