go:make_board: Changed makeBoard to accept a symbol to place in the array

This commit is contained in:
Logen Kain 2017-10-03 01:32:37 -07:00
parent c297adac81
commit 93e5494f70

View File

@ -8,7 +8,7 @@ func main() {
const boardY int = 7
const boardX int = 12
board := makeBoard(boardY, boardX)
board := makeBoard(boardY, boardX, "_")
// Pretend that the player did something in the middle
playerMoveY := boardY / 2
@ -20,7 +20,7 @@ func main() {
}
func makeBoard(sizeY, sizeX int) [][]string {
func makeBoard(sizeY, sizeX int, symbol string) [][]string {
//Make an array of empty strings
// Rows
board := make([][]string, sizeY)
@ -31,7 +31,7 @@ func makeBoard(sizeY, sizeX int) [][]string {
board[y] = make([]string, sizeX)
// and populate em
for x := 0; x < sizeX; x++ {
board[y][x] = "_ "
board[y][x] = symbol
}
}
return board