import turtle
class Stack:
def __init__(self):
self.items = []
def isEmpty(self):
return len(self.items) == 0
def push(self item):
self.items.append(item)
def pop(self):
return self.items.pop()
def peek(self):
if not self.isEmpty():
return self.items[len(self.items) - 1]
def size(self):
return len(self.items)
def drawpole(n): # 画柱子,距离500
t = turtle.Turtle()
t.hideturtle()
def pole(kn):
t.up()
t.pensize(10)
t.speed(100)
t.pencolor(‘green‘)
t.goto(30*n * (k - 1) n*15) #柱子高度可根据盘子数量变化
t.down()
t.goto(30*n * (k - 1) -150)
t.goto(30*n * (k - 1) - 40 -150)
t.goto(30*n * (k - 1) + 40 -150)
pole(0n) # 画柱子1
pole(1n) # 画柱子2
pole(2n) # 画柱子3
def creatPlates(n): # 创建盘子,传入数量
plates = [t
评论
共有 条评论