Class: Console_UI
- Inherits:
-
Object
- Object
- Console_UI
- Defined in:
- lib/console_ui.rb
Instance Method Summary collapse
- #ask_for_first_player ⇒ Object
- #ask_for_marker_type ⇒ Object
- #ask_for_opponent ⇒ Object
- #ask_for_square_to_mark ⇒ Object
- #ask_for_width_of_board ⇒ Object
- #ask_to_restart ⇒ Object
- #get_first_player ⇒ Object
- #get_input ⇒ Object
- #get_marker_type ⇒ Object
- #get_opponent ⇒ Object
- #get_square_to_mark ⇒ Object
- #get_width_of_board ⇒ Object
- #marker_error ⇒ Object
- #print_board(board) ⇒ Object
- #put_to_console(output) ⇒ Object
- #puts_tie ⇒ Object
- #puts_turn(marker) ⇒ Object
- #puts_winner(winning_marker) ⇒ Object
Instance Method Details
#ask_for_first_player ⇒ Object
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_type ⇒ Object
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_opponent ⇒ Object
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_mark ⇒ Object
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_board ⇒ Object
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_restart ⇒ Object
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_player ⇒ Object
23 24 25 |
# File 'lib/console_ui.rb', line 23 def get_first_player get_input end |
#get_input ⇒ Object
71 72 73 |
# File 'lib/console_ui.rb', line 71 def get_input gets.chomp.to_i end |
#get_marker_type ⇒ Object
19 20 21 |
# File 'lib/console_ui.rb', line 19 def get_marker_type gets.chomp end |
#get_opponent ⇒ Object
31 32 33 |
# File 'lib/console_ui.rb', line 31 def get_opponent get_input end |
#get_square_to_mark ⇒ Object
47 48 49 |
# File 'lib/console_ui.rb', line 47 def get_square_to_mark get_input end |
#get_width_of_board ⇒ Object
7 8 9 |
# File 'lib/console_ui.rb', line 7 def get_width_of_board get_input end |
#marker_error ⇒ Object
43 44 45 |
# File 'lib/console_ui.rb', line 43 def marker_error put_to_console("Input error.") end |
#print_board(board) ⇒ Object
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_tie ⇒ Object
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 |