Class: Tictactoe
- Inherits:
-
Object
- Object
- Tictactoe
- Defined in:
- lib/tictactoe.rb
Instance Method Summary collapse
-
#initialize ⇒ Tictactoe
constructor
A new instance of Tictactoe.
- #play_game ⇒ Object
Constructor Details
#initialize ⇒ Tictactoe
Returns a new instance of Tictactoe.
5 6 7 8 9 10 11 |
# File 'lib/tictactoe.rb', line 5 def initialize @moves = (0..8).to_a @computer_move = 4 @playing = true @message = "Please enter your move".blue @continue = true end |
Instance Method Details
#play_game ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/tictactoe.rb', line 13 def play_game play_tictactoe if play_until_win who_won = winner.first == 'X' ? 'Computer' : 'You' puts '********************' display_board puts "#{who_won} Won".neon elsif play_until_draw puts '********************' display_board puts "It's a draw".neon end end |