-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathRestaurant.java
More file actions
45 lines (31 loc) · 1.45 KB
/
Restaurant.java
File metadata and controls
45 lines (31 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import seii.*;
public class Restaurant{
public static void main( String[] args ){
RestaurantAbstractFactory restaurant1 =
new RestaurantFactoryProducer( ).getRestaurantAbstractFactory( 1 );
FastFood hamburger = restaurant1.getFastfood( "hamburger" );
FastFood.Builder builder = hamburger.builder( );
FastFood combo1 = builder
.addCorn( )
.addBacon( )
.addMushroom( )
.build( );
RestaurantOrder order1 = restaurant1.initOrder( );
order1.addItem( combo1 );
order1.addItem( restaurant1.getDrink( "soda" ) );
order1.addItem( restaurant1.getFastfood( "hot dog" ) );
System.out.println( order1 );
restaurant1.applyPromos( order1.getId( ) );
System.out.println( order1 );
RestaurantAbstractFactory restaurant2 =
new RestaurantFactoryProducer( ).getRestaurantAbstractFactory( 2 );
FastFood baconPizza = restaurant2.getFastfood( "pizza" ).builder( ).addBacon( ).addCorn( ).build( );
FastFood vegetarianPizza = restaurant2.getFastfood( "pizza" ).builder( ).addCorn( ).addMushroom( ).build( );
RestaurantOrder order2 = restaurant2.initOrder( );
order2.addItem( baconPizza );
order2.addItem( vegetarianPizza );
System.out.println( order2 );
restaurant2.applyPromos( order2.getId( ) );
System.out.println( order2 );
}
}