Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Die
- def initialize
- puts 'What\'s the number on the die now?'
- @side = gets.chomp
- if @side.to_i > 6
- puts "A die doesn\'t have #{@side.to_s} sides."
- elsif @side.to_s == ("a" .. "z")
- puts "#{@side} is not a number"
- exit
- end
- roll
- end
- def roll
- @number_showing = 1 + rand(6)
- end
- def total
- total = "Total: #{@number_showing + @side.to_i}"
- end
- end
- puts Die.new.total
Add Comment
Please, Sign In to add comment