Skip to content

Instantly share code, notes, and snippets.

@CafeFerguson
Last active August 29, 2015 14:18
Show Gist options
  • Save CafeFerguson/b85554bb675d009f7a63 to your computer and use it in GitHub Desktop.
Save CafeFerguson/b85554bb675d009f7a63 to your computer and use it in GitHub Desktop.
Ruby Learning Class - Chipotle Restaurant Food
class MenuItem
attr_accessor :type, :choiceMeat, :price
#All created classes will have 3 parameters + passed constants from the class @@name
def initialize(type, choiceMeat, price)
@type = type
@choiceMeat = choiceMeat
@price = price
end
#this is an instance method
def servedItem()
bt = MenuItem.new("taco", "beef", 6.00)
@bt = bt
print bt.class, "\n"
print bt.class.superclass, "\n"
puts "I ran servedItem method"
return bt.price
end
end
class ChipotleRestaurant
attr_accessor :numMeals, :valueMeals
def initialize(numMeals, valueMeals)
@numMeals = numMeals
@valueMeals = valueMeals
end
def getServed()
x = bt.servedItem()
print "Got this from MenuItem Class: ", "\n"
end
end
#Creates Restaurant and Menu
puts
cr = ChipotleRestaurant.new(0.0,0.0)
chickenSalad = MenuItem.new("salad", "chicken", 8.00)
beefSalad = MenuItem.new("salad", "beef", 9.00)
chickenTaco = MenuItem.new("taco", "chicken", 5.00)
beefTaco = MenuItem.new("taco", "beef", 6.00)
@beefTaco = beefTaco
cr.getServed()
#x = beefTaco.servedItem()
puts
puts "*** Menu ***"
print "#{chickenSalad.choiceMeat.capitalize}", " ", "#{chickenSalad.type.capitalize}", " \t= $", "#{chickenSalad.price}", "\n"
print "#{beefSalad.choiceMeat.capitalize}", " ", "#{beefSalad.type.capitalize}", " \t= $", "#{beefSalad.price}", "\n"
print "#{chickenTaco.choiceMeat.capitalize}", " ", "#{chickenTaco.type.capitalize}", " \t= $", "#{chickenTaco.price}", "\n"
print "#{beefTaco.choiceMeat.capitalize}", " ", "#{beefTaco.type.capitalize}", " \t= $", "#{beefTaco.price}", "\n"
puts
puts "*** Restaurant Statistics ***"
print "Number of Meals Served: ", "#{cr.numMeals}", " | ", "Total Value of Meals Served: ", "#{cr.valueMeals}", "\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment