Class: Console_UI

Inherits:
Object
  • Object
show all
Defined in:
lib/console_ui.rb

Instance Method Summary collapse

Instance Method Details

#ask_for_first_playerObject



11
12
13
# File 'lib/console_ui.rb', line 11

def ask_for_first_player
  put_to_console("Enter 'X' or 'O.'")
end

#ask_for_marker_typeObject



15
16
17
# File 'lib/console_ui.rb', line 15

def ask_for_marker_type
  put_to_console("Enter a character A-Z to serve as your marker type")
end

#ask_for_opponentObject



27
28
29
# File 'lib/console_ui.rb', line 27

def ask_for_opponent
  put_to_console("Enter 1 for computer opponent or any key for human opponent")
end

#ask_for_square_to_markObject



39
40
41
# File 'lib/console_ui.rb', line 39

def ask_for_square_to_mark
  put_to_console('Pick an empty square to mark: ')
end

#ask_for_width_of_boardObject



3
4
5
# File 'lib/console_ui.rb', line 3

def ask_for_width_of_board
  put_to_console("Enter 3 for a 3x3 board or 4 for a 4x4 board.")
end

#ask_to_restartObject



59
60
61
# File 'lib/console_ui.rb', line 59

def ask_to_restart
  put_to_console("Enter 1 to restart or any key to exit.")
end

#get_first_playerObject



23
24
25
# File 'lib/console_ui.rb', line 23

def get_first_player
  get_input
end

#get_inputObject



71
72
73
# File 'lib/console_ui.rb', line 71

def get_input
  gets.chomp.to_i
end

#get_marker_typeObject



19
20
21
# File 'lib/console_ui.rb', line 19

def get_marker_type
  gets.chomp
end

#get_opponentObject



31
32
33
# File 'lib/console_ui.rb', line 31

def get_opponent
  get_input
end

#get_square_to_markObject



47
48
49
# File 'lib/console_ui.rb', line 47

def get_square_to_mark
  get_input
end

#get_width_of_boardObject



7
8
9
# File 'lib/console_ui.rb', line 7

def get_width_of_board
  get_input
end

#marker_errorObject



43
44
45
# File 'lib/console_ui.rb', line 43

def marker_error
  put_to_console("Input error.")
end


63
64
65
# File 'lib/console_ui.rb', line 63

def print_board(board)
  put_to_console(board)
end

#put_to_console(output) ⇒ Object



67
68
69
# File 'lib/console_ui.rb', line 67

def put_to_console(output)
  puts output
end

#puts_tieObject



55
56
57
# File 'lib/console_ui.rb', line 55

def puts_tie
  put_to_console("Tie Game!")
end

#puts_turn(marker) ⇒ Object



35
36
37
# File 'lib/console_ui.rb', line 35

def puts_turn(marker) 
  put_to_console("It is #{marker}'s turn.")
end

#puts_winner(winning_marker) ⇒ Object



51
52
53
# File 'lib/console_ui.rb', line 51

def puts_winner(winning_marker)
  put_to_console("Player #{winning_marker} wins!")
end