Sha256: bd00dcc3b9457e6d29d1f09e5c4fa64b59141943f07fef47fb6c635a0ff52b2d

Contents?: true

Size: 947 Bytes

Versions: 2

Compression:

Stored size: 947 Bytes

Contents

# ********** LOADED DIE ******************
require_relative 'auditable'
module StudioGame
  class LoadedDie
      include Auditable
      attr_reader :number
    
      def roll
        numbers = [1, 1, 2, 5, 6, 6]
        @number = numbers.sample
        audit 
        @number # Lastly, return the @number value as the last expression in the method since the game expects roll to return a number.
      end
  end
end
  if __FILE__ == $0
    die = LoadedDie.new()
    die.roll # displays "Rolled a # (Die)" because ROLL calls the audit as defined within the roll method
             # note that this die.roll is also testing that the audit method (mixin) from the Auditable module works.
    puts "\nThis is the number: #{die.number}" #with the die object, you can call the readable number attribute with .number
    puts "This is the class: #{die.class}" #with the die object, you can call the object class with .class
  end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
j_studio_game-1.0.2 lib/loaded_die.rb
j_studio_game-1.0.1 lib/loaded_die.rb