Guest User

Untitled

a guest
Feb 21st, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. class Die
  2. def initialize
  3. puts 'What\'s the number on the die now?'
  4. @side = gets.chomp
  5. if @side.to_i > 6
  6. puts "A die doesn\'t have #{@side.to_s} sides."
  7. elsif @side.to_s == ("a" .. "z")
  8. puts "#{@side} is not a number"
  9. exit
  10. end
  11. roll
  12. end
  13. def roll
  14. @number_showing = 1 + rand(6)
  15. end
  16. def total
  17. total = "Total: #{@number_showing + @side.to_i}"
  18. end
  19. end
  20.  
  21. puts Die.new.total
Add Comment
Please, Sign In to add comment