class Taste
attr soybean_sauce, pepper, glutamate
def initialize(soybean_sauce, pepper, glutamate)
@soybean_sauce = soybean_sauce
@pepper = pepper
@glutamate = glutamate
end
def display
puts "菜的调料含量: 酱油#{@soybean_sauce}, 辣椒#{@pepper},味精#{glutamate}"
end
end
prototype_manager = Hash.new
prototype_manager["温州口味"] = Taste.new("少量", "微乎其微", "越多越好")
prototype_manager["杭州口味"] = Taste.new("少量", "不多", "很少")
order = "温州口味"
food_taste = prototype_manager["温州口味"].clone
food_taste.display
[img]http://dl.iteye.com/upload/attachment/194753/3011ef62-9378-3dcd-8d0f-89239151cf06.gif[/img]