0

I'm receiving an Uninitialized constant error from my code. I have searched around with no luck. Any help would be highly appreciated.

Class Die

    def initialize 

        roll
    end

    def roll

        @num_showing = 1 + rand(6)
    end

    def showing

        @num_showing
    end

    def cheat
        puts "Enter the die # (1-6)"
        @num_showing = gets.chomp
        while @numshowing > 6 and @numshowing < 0

            puts "Enter the die # (1-6)"
            @num_showing = gets.chomp

        end
    end

puts Die.new.cheat
Piccolo
  • 1,612
  • 4
  • 22
  • 38
LaurentL
  • 203
  • 1
  • 3
  • 11

1 Answers1

2
  1. Change Class to class
  2. Add an extra end at the end of the class definition. Looks like you're not closing the while loop.
Matt
  • 20,108
  • 1
  • 57
  • 70