Skip to content

Instantly share code, notes, and snippets.

@jordanpoulton
Created March 4, 2013 17:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jordanpoulton/5084121 to your computer and use it in GitHub Desktop.
Save jordanpoulton/5084121 to your computer and use it in GitHub Desktop.
Cake script
#!/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