class MegaRps::Game

Game

handle game logic/flow

Player

Make move

Human < Player

Collect input from command line

Computer < Player

Generate move randomly

Public Class Methods

new() click to toggle source
# File lib/mega_rps.rb, line 18
def initialize

        @player = Human.new
        @computer = Computer.new

end

Public Instance Methods

play_again?() click to toggle source
# File lib/mega_rps.rb, line 67
def play_again?

  puts "Would you like to play again? Y/N"

  if gets.chomp[0].downcase == 'y'
    true
  else 
    false
  end
end
play_game() click to toggle source
# File lib/mega_rps.rb, line 26
def play_game

        print_instructions

        while play_again?
                @player.move
                @computer.move
                print_result
                play_again?
        end

end
print_instructions() click to toggle source
print_result() click to toggle source