绘制方形函数swift

时间:2017-09-05 04:24:47

标签: swift function drawing

我正在尝试创建一个接受大小参数的新drawSquare函数。这将允许一个函数创建多个大小的正方形!

这是我写的代码。我知道我犯了一个小错误,请帮忙。

func drawSquare(sideLength: Int) {
    move(sidelength) 
} 
drawSquare(sideLength: 150) 

1 个答案:

答案 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)