Skip to content

Commit 29c5c40

Browse files
committed
修改笔误
1 parent 1dd5afb commit 29c5c40

File tree

1 file changed

+37
-38
lines changed

1 file changed

+37
-38
lines changed

第二章-构造器模式.md

Lines changed: 37 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,6 @@ class MargaritaBuilder:
360360
self.pizza = Pizza('margarita')
361361
self.progress = PizzaProgress.queued
362362
self.baking_time = 5 # in seconds for the sake of the
363-
example
364363

365364
def prepare_dough(self):
366365
self.progress = PizzaProgress.preparation
@@ -402,53 +401,53 @@ class CreamyBaconBuilder:
402401
self.pizza = Pizza('creamy bacon')
403402
self.progress = PizzaProgress.queued
404403
self.baking_time = 7 # in seconds for the sake of the
405-
example
406404

407405
def prepare_dough(self):
408-
self.progress = PizzaProgress.preparation
409-
self.pizza.prepare_dough(PizzaDough.thick)
406+
self.progress = PizzaProgress.preparation
407+
self.pizza.prepare_dough(PizzaDough.thick)
410408

411409
def add_sauce(self):
412-
print('adding the crème fraîche sauce to your creamy bacon')
413-
self.pizza.sauce = PizzaSauce.creme_fraiche
414-
time.sleep(STEP_DELAY)
415-
print('done with the crème fraîche sauce')
410+
print('adding the crème fraîche sauce to your creamy bacon')
411+
self.pizza.sauce = PizzaSauce.creme_fraiche
412+
time.sleep(STEP_DELAY)
413+
print('done with the crème fraîche sauce')
416414

417415
def add_topping(self):
418-
print('adding the topping (mozzarella, bacon, ham, mushrooms, red onion, oregano) to your creamy bacon')
419-
self.pizza.topping.append([t for t in
420-
(PizzaTopping.mozzarella, PizzaTopping.bacon,
421-
PizzaTopping.ham,PizzaTopping.mushrooms,
422-
PizzaTopping.red_onion, PizzaTopping.oregano)])
423-
time.sleep(STEP_DELAY)
424-
print('done with the topping (mozzarella, bacon, ham, mushrooms, red onion, oregano)')
416+
print('adding the topping (mozzarella, bacon, ham, mushrooms, red onion, oregano) to your creamy bacon')
417+
self.pizza.topping.append([t for t in
418+
(PizzaTopping.mozzarella, PizzaTopping.bacon,
419+
PizzaTopping.ham,PizzaTopping.mushrooms,
420+
PizzaTopping.red_onion, PizzaTopping.oregano)])
421+
time.sleep(STEP_DELAY)
422+
print('done with the topping (mozzarella, bacon, ham, mushrooms, red onion, oregano)')
425423

426424
def bake(self):
427-
self.progress = PizzaProgress.baking
428-
print('baking your creamy bacon for {} seconds'.format(self.baking_time))
429-
time.sleep(self.baking_time)
430-
self.progress = PizzaProgress.ready
431-
print('your creamy bacon is ready')
425+
self.progress = PizzaProgress.baking
426+
print('baking your creamy bacon for {} seconds'.format(self.baking_time))
427+
time.sleep(self.baking_time)
428+
self.progress = PizzaProgress.ready
429+
print('your creamy bacon is ready')
432430

433431

434-
class Waiter:
435-
def __init__(self):
436-
self.builder = None
437-
def construct_pizza(self, builder):
438-
self.builder = builder
439-
[step() for step in (builder.prepare_dough,
440-
builder.add_sauce, builder.add_topping, builder.bake)]
441-
@property
442-
def pizza(self):
443-
return self.builder.pizza
444-
445-
def validate_style(builders):
446-
try:
447-
pizza_style = input('What pizza would you like, [m]argarita or [c]reamy bacon? ')uilder = builders[pizza_style]() valid_input = True
448-
except KeyError as err:
449-
print('Sorry, only margarita (key m) and creamy bacon (key c) are available')
450-
return (False, None)
451-
return (True, builder)
432+
class Waiter:
433+
def __init__(self):
434+
self.builder = None
435+
def construct_pizza(self, builder):
436+
self.builder = builder
437+
[step() for step in (builder.prepare_dough,
438+
builder.add_sauce, builder.add_topping, builder.bake)]
439+
@property
440+
def pizza(self):
441+
return self.builder.pizza
442+
def validate_style(builders):
443+
try:
444+
pizza_style = input('What pizza would you like,[m]argarita or [c]reamy bacon? ')
445+
builder = builders[pizza_style]()
446+
valid_input = True
447+
except KeyError as err:
448+
print('Sorry, only margarita (key m) and creamy bacon (key c) are available')
449+
return (False, None)
450+
return (True, builder)
452451

453452

454453
def main():

0 commit comments

Comments
 (0)