Skip to content

Instantly share code, notes, and snippets.

@jordanpoulton
Created February 27, 2013 18:05
Show Gist options
  • Save jordanpoulton/5050057 to your computer and use it in GitHub Desktop.
Save jordanpoulton/5050057 to your computer and use it in GitHub Desktop.
A programme that bakes an Umbongo flavoured cake then bakes one for you...
#!/usr/bin/env ruby
class Order
def initialize(cake_flavour)
puts "----------------->You've initialised a new order for a cake"
puts "
You want a #{cake_flavour} flavoured cake?
Let's go.
"
@cake_flavour = cake_flavour
puts ".........Now I'm going to bake the cake......."
bake_cake
end
def bake_cake
@batter = []
pour_flour
add_egg
stir_batter
return Cake.new(@cake_flavour)
end
def pour_flour
@batter.push(Flour.new)
puts "The FIRST ingredient is you add flour BY INITIALIZING THE FLOUR CLASS"
end
def add_egg
@batter.push(Egg.new)
puts "Then you add the egg to the mix: INITialize ANOTHER EGG CLASS, and like the flour class did just now you push it into the batter array with @batter.push(Egg.new)"
end
def stir_batter
puts "then you stir the batter"
end
end
class Cake
def initialize(batter)
@batter = batter
@baked = true
puts " The CAKE CLASS HAS BEEN INITIALIZED
Your baker has created a #{batter} flavoured cake for you"
puts "Diiiiiiiiiiing....... That's your cake ready! Get it while it's Hot!!!"
end
end
class Egg
def initialize
puts "Then you create and Egg"
end
end
class Flour
end
#****************** START THE PROGRAMME ***************
puts "
-
-
-
ORDER 1 RECEIVED!!!!!!!!!!!!!!"
order_1 = Order.new("*****UMBONGO*****")
puts "What would you like to order?"
next_order = gets.chomp
puts "
THE BAKER WILL NOW BAKE THE CAKE YOU ASKED FOR.......
#{next_order.upcase} coming up"
user_order = Order.new("#{next_order.upcase}")
puts "
Maybe the next step could be to add a buyer class, maybe more types of cakes, more ingredients....
"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment