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 #1

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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ Notice that we've already given you the `#display_board` method, since we've alr

#### `#input_to_index`


Your `#input_to_index` method must take one argument, the user's input (should be a string that is "1" - "9").

Regarding the player's input: if the user's input is `"5"`, the player wants to fill out position 5 with their character. This means that your method must fill out the correct array index with the player's character.
Expand Down
12 changes: 11 additions & 1 deletion bin/move
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,14 @@

require_relative '../lib/move.rb'

# Code your CLI Here
# Code your CLI Here

board = [" ", " ", " ", " ", " ", " ", " ", " ", " "]

puts "Welcome to Tic Tac Toe!"
puts "Please enter 1-9:"
user_input = gets.strip

index = input_to_index(user_input)
move(board, index, "X")
display_board(board)
8 changes: 8 additions & 0 deletions lib/move.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,11 @@ def display_board(board)
end

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


def move(board, index, char = "X")
board[index] = char
end