Last active
December 24, 2015 08:39
-
-
Save rayning0/6771721 to your computer and use it in GitHub Desktop.
Deli Counter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def take_a_number(katz, name) | |
| katz << name | |
| return katz.size | |
| end | |
| def line(katz) | |
| print "The line is currently:" | |
| katz.each_with_index do |name, i| | |
| print " #{i + 1}. #{name}" | |
| end | |
| puts | |
| end | |
| def now_serving(katz) | |
| puts "Currently serving #{katz[0]}" | |
| katz.shift | |
| end | |
| katz_deli = [] | |
| puts take_a_number(katz_deli, "Ada") #=> "1" | |
| puts take_a_number(katz_deli, "Grace") #=> "2" | |
| puts take_a_number(katz_deli, "Kent") #=> "3" | |
| line(katz_deli) #=> "The line is currently: 1. Ada 2. Grace 3. Kent" | |
| now_serving(katz_deli) #=> "Currently serving Ada" | |
| line(katz_deli) #=> "The line is currently: 1. Grace 2. Kent" | |
| p take_a_number(katz_deli, "Matz") #=> "3" | |
| line(katz_deli) #=> "The line is currently: 1. Grace 2. Kent 3. Matz" | |
| now_serving(katz_deli) #=> "Currently serving Grace" | |
| line(katz_deli) #=> "1. Kent 2. Matz" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment