Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String[] arguments) throws DuplicateProductException {
- Restaurant restoran = new Restaurant("Restaurant");
- SimpleProduct simple1=new SimpleProduct("simple1", 1f);
- SimpleProduct simple2=new SimpleProduct("simple2", 2f);
- SimpleProduct simple3=new SimpleProduct("simple3", 3f);
- SimpleProduct simple4=new SimpleProduct("simple4", 4f);
- SimpleProduct simple5=new SimpleProduct("simple5", 5f);
- ExtendedProduct extended1=new ExtendedProduct("extended 1",11f);
- ExtendedProduct extended2=new ExtendedProduct("extended 2",12f);
- ExtendedProduct extended3=new ExtendedProduct("extended 3",13f);
- ExtendedProduct extended4=new ExtendedProduct("extended 4",14f);
- ExtendedProduct extended5=new ExtendedProduct("extended 5",15f);
- CompositeProduct composite1 = new CompositeProduct("composite 1",1f);
- composite1.addProduct(simple1);
- CompositeProduct composite2 = new CompositeProduct("composite 2",2f);
- composite2.addProduct(extended1);
- CompositeProduct composite3 = new CompositeProduct("composite 3",3f);
- composite3.addProduct(composite2);
- CompositeProduct composite4 = new CompositeProduct("composite 4",4f);
- composite4.addProduct(composite1);
- restoran.addProduct(simple1);
- restoran.addProduct(simple2);
- restoran.addProduct(simple3);
- restoran.addProduct(simple4);
- restoran.addProduct(simple5);
- restoran.addProduct(extended1);
- restoran.addProduct(extended2);
- restoran.addProduct(extended3);
- restoran.addProduct(extended4);
- restoran.addProduct(extended5);
- restoran.addProduct(composite1);
- restoran.addProduct(composite2);
- restoran.addProduct(composite3);
- restoran.addProduct(composite4);
- //restoran.addProduct(simple2); //duplicate
- Table table1= new Table("table 1");
- Table table2= new Table("table 2");
- Table table3= new Table("table 3");
- restoran.CreateTable("table 1");
- restoran.CreateTable("table 2");
- restoran.CreateTable("table 3");
- restoran.orderProductForTable(table1,simple1);
- restoran.orderProductForTable(table1, simple2, 2);
- restoran.orderProductForTable(table2,extended2,3);
- restoran.orderProductForTable(table2, composite3);
- restoran.orderProductForTable(table3, composite1);
- restoran.orderProductForTable(table3, extended4, 4);
- System.out.println(restoran.toString());
- if(restoran.findProduct("simple1") != null)
- {
- System.out.println("Product named '" +"' exists.");
- }
- boolean choice=true;
- Scanner input = new Scanner(System.in);
- while(choice)
- {
- int c = 0;
- System.out.println("1 <--- Search");
- System.out.println("2 <-- Add");
- c = input.nextInt();
- switch(c)
- {
- case 1:
- {
- System.out.println("Choose name: ");
- String str = input.next();
- if(restoran.findProduct(str) != null)
- {
- System.out.println("Product named '" + str + "' exists.");
- }else
- {
- System.out.println("Product named '" + str + "' doesn't exist.");
- }
- break;
- }
- case 2:
- {
- System.out.println("Choose name: ");
- String str = input.next();
- System.out.println("Choose price: ");
- float cost = input.nextFloat();
- try
- {
- restoran.addProduct(new SimpleProduct(str, cost));
- }catch(DuplicateProductException ex)
- {
- System.out.println(ex.getMessage());
- }
- break;
- }
- }
- }
- input.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement