I have two classes one has a menu and the other processes some
calculations.
class Menu
initialize variables(type, meat, price)
#create attr_accessors of each
attr_accessor :type
attr_accessor :meat
attr_accessor :price
def order
puts type, meat and price
end
end
#second class Restaurant
class Restaurant < Menu
def countorder
# some code
#puts how many ordered so far
end
def earned
# some code
#puts how much was the order so far
end
end
object = Restaurant.new( :Pizza, :Ham, 15.0 )
firstorder = object.order #will puts type, meat and price of order
puts object #should puts order # and the total ordered
object2 = Restaurant.new(:Salad, :Beef, 7.50)
firstorder = object2.order #will puts type, meat and price of order
puts object2 #shoudl then show order #2 and total of 15 + 7.50
I’m having some scope issues I’m not sure how to calculate and track the
count of order on the subclass and do total = total + @price.