我使用的是Mac OS X 10.8.2,并使用JDK 7.现在我下载了最新版本的IDEA IntelliJ,11.但是没有JDK 6它似乎没有开始.有没有解决方法?
如何在Mac OS X上使用JDK 7运行IDEA IntelliJ?
class Point:
def __init__(self, xcoord=0, ycoord=0):
self.x = xcoord
self.y = ycoord
class Rectangle:
def __init__(self, bottom_left, top_right, colour):
self.bottom_left = bottom_left
self.top_right = top_right
self.colour = colour
def intersects(self, other):
Run Code Online (Sandbox Code Playgroud)
我试图看看两个矩形是否基于右上角和左下角相交,但是当我创建函数时:
def intersects(self, other):
return self.top_right.x>=other.top_right.x>=self.bottom_left.x and self.top_right.x>=other.bottom_left.x>=self.bottom_left.x and self.top_right.y>=other.top_right.y>=self.bottom_left.y and self.top_right.x>=other.bottom_left.x>=self.bottom_left.x
Run Code Online (Sandbox Code Playgroud)
输入时该函数将返回false:
r1=Rectangle(Point(1,1), Point(2,2), 'blue')
r3=Rectangle(Point(1.5,0), Point(1.7,3), 'red')
r1.intersects(r3)
Run Code Online (Sandbox Code Playgroud)
进壳.