Sha256: 7c18363934e2368c221491a013779ab5939288082954fe14a5486bc32c63ce19
Contents?: true
Size: 782 Bytes
Versions: 2
Compression:
Stored size: 782 Bytes
Contents
module Codebreaker class Player attr_accessor :name, :player_code, :score def initialize(score = 0) @name = input_name @player_code = '' @score = score end def guess print 'Type your secret code or "hint": ' @player_code = input_code end def agree? input =~ /^(yes|y)$/i ? true : false end private def input STDIN.gets.chomp end def input_name print 'Please, enter your name: ' input end def input_code player_code = input if player_code.size == Codebreaker::Game::CODE_SIZE || player_code == 'hint' player_code else puts 'You should type 4 numbers in code or "hint"!!!' input_code end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
Codebreaker_RG2016-0.1.6 | lib/codebreaker/player.rb |
Codebreaker_RG2016-0.1.5 | lib/codebreaker/player.rb |