Advertisement
Guest User

Untitled

a guest
Dec 4th, 2011
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class StudyingStudents
  2.   def initialize
  3.     print "\n\nHow many subjects are we talking about? Enter an integer: "
  4.     @quantity = $stdin.gets.chomp.to_i
  5.     print "\n\nWhat type of subject are we talking about? Enter a singular string: "
  6.     @subject = $stdin.gets.chomp.downcase
  7.     @subject_plural = @subject + "s"
  8.     print "\n\nWhat is the exact location in question? Enter a brief string: "
  9.     @location = $stdin.gets.chomp.downcase
  10.   end
  11.  
  12.   def is_empty?
  13.     @quantity.zero? # == 0?
  14.   end
  15.  
  16.   def start_staring # action begins here
  17.      puts keep_staring("are furiously studying at the #{@location}. ") + one_gets_frustrated + keep_staring(" remain at the #{@location}")
  18.   end
  19.  
  20.   def keep_staring(context="") # output starts here ... main stanza
  21.     "#{(@quantity > 0)? @quantity.to_s : 'No more' } " "#{(@quantity == 1)?  @subject : @subject_plural}" + context
  22.   end
  23.  
  24.   def one_gets_frustrated
  25.      print "One leaves to go home, bake a rhubarb pie, and call it a day. "
  26.      @quantity -= 1
  27.      end
  28. end
  29.  
  30. lair = StudyingStudents.new
  31. lair.start_staring until lair.is_empty?
  32.  
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement