Answer the question
In order to leave comments, you need to log in
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)
Answer the question
In order to leave comments, you need to log in
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 questionAsk a Question
731 491 924 answers to any question