Last active
January 6, 2018 19:18
-
-
Save Sihui/a04f7ad82579d32a492bde9945a61bcc to your computer and use it in GitHub Desktop.
Design Pattern: Builder and Car
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 | |
def add_engine | |
car << " with an engine\n" | |
end | |
def add_front_wheels | |
car << " with two front wheels\n" | |
end | |
def add_back_wheels | |
car << " with two back wheels\n" | |
end | |
def add_dashboard | |
car << " with a dashboard\n" | |
end | |
def add_energy_source | |
car << " with a fuel tank\n" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment