@@ -265,11 +265,17 @@ def add_on_decorators(self, pizza_builder):
265265
266266 return pizza_builder
267267
268- def pay (self , pizza : Pizza , user : User ):
269- if isinstance (pizza , str ):
270- pizza = PizzaBuilder (pizza ).build ()
268+ def review_order (self ):
269+ print (f"\n { Fore .YELLOW } Current Order:{ Style .RESET_ALL } " )
270+ print (self .MENU_BORDER )
271+ for idx , pizza in enumerate (self .order .pizzas , 1 ):
272+ print (f"{ Fore .GREEN } { idx } .{ Style .RESET_ALL } { pizza } " )
273+ print (self .MENU_BORDER )
274+
275+ def pay (self , order : Order , user : User ):
276+ total_price = sum (pizza .price .price for pizza in order .pizzas )
271277 self .print_header ("Payment" )
272- print (f"{ Fore .GREEN } Total Amount:{ Style .RESET_ALL } ${ pizza . price . price :.2f} " )
278+ print (f"{ Fore .GREEN } Total Amount:{ Style .RESET_ALL } ${ total_price :.2f} " )
273279 print (
274280 f"{ Fore .YELLOW } Available Loyalty Points:{ Style .RESET_ALL } { user .get_loyalty } "
275281 )
@@ -297,7 +303,7 @@ def pay(self, pizza: Pizza, user: User):
297303 print ("Please enter a number between 1-3." )
298304
299305 # Initialize payment with selected strategy
300- payment = Payment (pizza . price , user , payment_strategies [choice ])
306+ payment = Payment (total_price , user , payment_strategies [choice ])
301307
302308 use_loyalty = (
303309 input ("Do you want to use your loyalty points? (y/n)" ).lower () == "y"
@@ -410,13 +416,19 @@ async def main(self):
410416 user = self .authentication ()
411417 while True :
412418 self .order = Order (user )
413- pizza = self .add_on_decorators (self .home_page (user )).build ()
414- user .add_order (pizza )
419+ while True :
420+ pizza = self .add_on_decorators (self .home_page (user )).build ()
421+ self .order .add_pizza (pizza )
422+ user .add_order (pizza )
423+ self .review_order ()
424+ if input ("Add another pizza to this order? (y/n): " ).lower () == "n" :
425+ break
415426 tracker = self .get_tracker ()
416- self .pay (pizza , user )
427+ self .pay (self . order , user )
417428 print (f"\n { Fore .GREEN } Payment successful!{ Style .RESET_ALL } " )
418429 tracking = asyncio .create_task (self .tracking (self .order , tracker ))
419430 tracking = await tracking
420- self .feedback (pizza )
421- if input ("Order Another Pizza?" ).lower ().lower () == "n" :
431+ for pizza in self .order .pizzas :
432+ self .feedback (pizza )
433+ if input ("Place another order? (y/n): " ).lower () == "n" :
422434 break
0 commit comments