Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class StudyingStudents
- def initialize
- print "\n\nHow many subjects are we talking about? Enter an integer: "
- @quantity = $stdin.gets.chomp.to_i
- print "\n\nWhat type of subject are we talking about? Enter a singular string: "
- @subject = $stdin.gets.chomp.downcase
- @subject_plural = @subject + "s"
- print "\n\nWhat is the exact location in question? Enter a brief string: "
- @location = $stdin.gets.chomp.downcase
- end
- def is_empty?
- @quantity.zero? # == 0?
- end
- def start_staring # action begins here
- puts keep_staring("are furiously studying at the #{@location}. ") + one_gets_frustrated + keep_staring(" remain at the #{@location}")
- end
- def keep_staring(context="") # output starts here ... main stanza
- "#{(@quantity > 0)? @quantity.to_s : 'No more' } " "#{(@quantity == 1)? @subject : @subject_plural}" + context
- end
- def one_gets_frustrated
- @quantity -= 1
- print "One leaves to go home, bake a rhubarb pie, and call it a day. "
- end
- end
- lair = StudyingStudents.new
- lair.start_staring until lair.is_empty?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement