我正在尝试创建一个接受大小参数的新drawSquare
函数。这将允许一个函数创建多个大小的正方形!
这是我写的代码。我知道我犯了一个小错误,请帮忙。
func drawSquare(sideLength: Int) {
move(sidelength)
}
drawSquare(sideLength: 150)
答案 0 :(得分:-2)
格式正确
func drawSquare(sideLength: Int) {
move(steps:sideLength)
rotate(degrees: sideLength)
move(steps: sideLength)
rotate(degrees: sideLength)
move(steps: sideLength)
rotate(degrees: sideLength)
move(steps: sideLength)
}
drawSquare(sideLength: 90)