Skip to content

Instantly share code, notes, and snippets.

@makersacademy
Created March 1, 2013 17:15
Show Gist options
  • Save makersacademy/5066187 to your computer and use it in GitHub Desktop.
Save makersacademy/5066187 to your computer and use it in GitHub Desktop.
Ideas for an exericise
# Bicycles, docking stations, vans, central system to control the vans, people
# people would ride bikes
# vans would move them around
# a central station would control the vans
# repair facility would take the broken bikes and fix them
# repaired bikes would be delivered to stations
# report on the most/least used stations
# bikes would be taken out of service after 1000 rides
station # => it would have 15 bikes
people # => 100
class Person
def initialize
@riding_a_bike = false
end
def riding_a_bike?
@riding_a_bike
end
def take_a_bike(station)
@riding_a_bike = true
end
end
5.times do
people.each{|p| p.take_a_bike(station) if rand < 0.05 }
people.select{|p| p.riding_a_bike? }.each{|p| p.return_a_bike(station) if rand < 0.05 }
puts Boris.general_report
# => 1 station, 10 bikes, 4 taken out
sleep 1
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment