This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PizzaStore | |
attr_accessor :pizza_prototype_collection | |
def initialize | |
@pizza_prototype_collection = {} | |
end | |
def take_order(pizza_type) | |
pizza_prototype = pizza_prototype_collection[pizza_type] | |
raise 'unsupported pizza type' unless pizza_prototype |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PizzaStore | |
def take_order(pizza_type) | |
case pizza_type | |
when 'matcha' | |
pizza = Pizza.new('Matcha Pizza', ['matcha powder']) | |
when 'pepperoni' | |
pizza = Pizza.new('Pepperoni Pizza', ['pepperoni', 'shredded mozzarella cheese']) | |
when 'chicken' | |
pizza = Pizza.new('Chicken Pizza', ['chicken', 'mushroom', 'spinach']) | |
else |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PizzaStore | |
def take_order(pizza_type) | |
case pizza_type | |
when 'pepperoni' | |
pizza = Pizza.new('Pepperoni Pizza', ['pepperoni', 'shredded mozzarella cheese']) | |
when 'chicken' | |
pizza = Pizza.new('Chicken Pizza', ['chicken', 'mushroom', 'spinach']) | |
else | |
pizza = Pizza.new('Cheese Pizza', ['cheese']) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Pizza | |
attr_reader :name, :toppings, :state | |
def initialize(name, toppings) | |
@name = name | |
@toppings = toppings | |
@state = 'raw' | |
end | |
def bake |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CarConstructionDirector | |
def construct_car(builder:) | |
builder.build_car_frame | |
builder.add_engine | |
builder.add_front_wheels | |
builder.add_back_wheels | |
builder.add_dashboard | |
builder.add_energy_source | |
builder.car | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ElectronicCarBuilder | |
attr_reader :car | |
def initialize | |
@car = '' | |
end | |
def build_car_frame | |
car << "This is an electronic car\n" | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SportsCarBuilder | |
attr_reader :car | |
def initialize | |
@car = '' | |
end | |
def build_car_frame | |
car << "This is a sport car\n" | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class StandardCarBuilder | |
attr_reader :car | |
def initialize | |
@car = '' | |
end | |
def build_car_frame | |
car << "This is a standard car\n" | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ElectronicCarBuilder | |
def build | |
car = '' | |
# 1. build car frame | |
car << "This is an electronic car\n" | |
# 2. add an engine | |
car << " with a electronic engine\n" | |
# 3. add front wheels | |
car << " with two front wheels\n" | |
# 4. add back wheels |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SportsCarBuilder | |
def build | |
car = '' | |
# 1. build car frame | |
car << "This is a sport car\n" | |
# 2. add an engine | |
car << " with a powerful engine\n" | |
# 3. add front wheels | |
car << " with two front wheels suitable for mountain paths\n" | |
# 4. add back wheels |
NewerOlder