A
A
Aleksandr Govorukhin2015-11-16 16:44:26
Swift
Aleksandr Govorukhin, 2015-11-16 16:44:26

Missing argument for parameter, what to do?

What is he swearing at? How to solve the problem? I set the parameters of the tuples, help me figure it out. The bottom line is that a chessboard will be drawn with figures that are in a tyuple, the code was thrown off by a screen and there is an error that I can’t solve.

let tuplQueen = (figure: "\u{2655}", positionX: 7, positionY: 5)
let tuplPawn = (figure: "Pawn", positionX: 5, positionY: 5)

let tuplArray = [tuplPawn, tuplQueen]


func drawBoard (figure: String, positionX: Int, positionY: Int) -> (){
    var board = ""
        for i in 1..<8 {
            board += "\n"
        for j in 1..<8 {
            if i == positionY && j == positionX{
                board += figure
            } else {
            board += (i + j) % 2 == 0 ? "\u{2B1C}" : "\u{2B1B}" //черный
            }
    }
}
print(board)
}
drawBoard(tuplQueen)

8fd7e5532a9a48d2ad7e1796c8354977.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Aleksandr Govorukhin, 2015-11-16
@SnapSh0t

decided everything.

let tuplQueen = (figure: "\u{2655}", positionX: 7, positionY: 5)
let tuplPawn = (figure: "Pawn", positionX: 5, positionY: 5)

let tuplArray = [tuplPawn, tuplQueen]
let length = tuplArray.count

func drawBoard (figure: String, positionX: Int, positionY: Int) -> (){
    var board = ""
        for i in 1..<8 {
            board += "\n"
        for j in 1..<8 {
            if i == positionY && j == positionX{
                board += figure
            } else {
            board += (i + j) % 2 == 0 ? "\u{2B1C}" : "\u{2B1B}" //черный
            }
    }
}
print(board)
}
for i in 1..<length {
 drawBoard(tuplArray[i].figure, positionX: tuplArray[i].positionX, positionY: tuplArray[i].positionY)
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question