class Shape:
def __init__(self,x,y):
self.x = x
self.y = y
class Rect(Shape):
def __init__(self,x,y,w,h):
super().__init__(x,y)
self.w = w
self.h = h
def is_in(self,x1,y1):
if x1 <= (self.x + self.w) and y1 <= (self.y + self.h):
print("该点在矩形内")
else:
print("该点不在矩形内")
s = Rect(1,1,5,4)
s.is_in(5,5)
Python | 练习作业4
最新推荐文章于 2024-09-15 22:31:42 发布