Skip to content

Instantly share code, notes, and snippets.

@ksin
Created August 6, 2015 02:59
Show Gist options
  • Save ksin/2e0d4ca4dfe9f2c43d1e to your computer and use it in GitHub Desktop.
Save ksin/2e0d4ca4dfe9f2c43d1e to your computer and use it in GitHub Desktop.
#Cookies & Ovens
#Oven
#-on, off -empty, full
#-temperature -how many cookies it has?
#-store cookies in it. making instances of Cookie and passing them into Oven
#oven has many cookies
#Cookie
#-doughy, baked, burnt
#-recipe
#Scheduler
#-empty, full (list of things to do)
#-priority
#STATES
#ATTRIBUTES
#INTERFACES
class Oven
attr_accessor :cookies
attr_reader :capacity
def initialize(capacity)
@cookies = []
@temperature = 22
@capacity = capacity
end
def place_cookies(*new_cookies)
cookies << new_cookies
end
def full?
cookies.length >= capacity
end
def empty?
cookies.length = 0
end
# perhaps there's a bake method. perhaps it's separate from a turn on / turn off (toggle)
def bake
end
def peek
end
end
class Cookie
def initialize(recipe)
end
end
class ChocolateChip < Cookie
end
class PeanutButter < Cookie
end
###
cookie1 = Cookie.new() # pass in recipe
cookie2 = Cookie.new() #...
oven = Oven.new() # pass some stuff into oven
oven.place_cookies(cookie1, cookie2)
sleep 2
sleep 5
# try to puts out any messages
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment