Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Done #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion bin/move
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,11 @@

require_relative '../lib/move.rb'

# Code your CLI Here
# Code your CLI Here
board = [" ", " ", " ", " ", " ", " ", " ", " ", " "]
puts "Welcome to Tic Tac Toe!"
puts "Where would you like to go?"
input = gets.strip
index = input_to_index(input)
move(board, index,)
display_board(board)
10 changes: 10 additions & 0 deletions lib/move.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
board = ["","","","","","","","",""]
def display_board(board)
puts " #{board[0]} | #{board[1]} | #{board[2]} "
puts "-----------"
Expand All @@ -7,3 +8,12 @@ def display_board(board)
end

# code your input_to_index and move method here!
#input_to_index
def input_to_index(input)
return input.to_i - 1
end

#move
def move(board, index, character = "X")
return board[index] = character
end