]> git.somenet.org - pub/jan/sbc.git/blob - src/main/java/at/ac/tuwien/sbc/valesriegler/types/Pizza.java
cook pizza orders and let the waiters to deliver them.
[pub/jan/sbc.git] / src / main / java / at / ac / tuwien / sbc / valesriegler / types / Pizza.java
1 package at.ac.tuwien.sbc.valesriegler.types;
2
3 import java.io.Serializable;
4
5 import at.ac.tuwien.sbc.valesriegler.common.Util;
6 import at.ac.tuwien.sbc.valesriegler.waiter.Waiter;
7
8 /**
9  * this is a PIZZA! omnomnomnom
10  * 
11  * @author jan
12  * 
13  */
14 public class Pizza extends PizzaOrder implements Serializable {
15         public Waiter deliveryAgent;
16
17         /**
18          * Yes that's funny! the pizza has a field idOfOrder although PizzaOrder
19          * already has a field orderId! The reason: The space linda selection is a
20          * little bit limited. when I look for a template pizza with orderId set the
21          * space gives me ALL pizzas. The reason obviously is that it can't really
22          * include the field of the superclass in the search. So we must have an
23          * idOfOrder field in the pizza and not only in the PizzaOrder for the time
24          * being.. ^^
25          */
26         private Integer idOfOrder;
27
28         // private Person consumer;
29
30         private Pizza(int id, PizzaType type, int cookId, int orderId) {
31                 super(id);
32                 this.id = id;
33                 pizzaType = type;
34                 this.cookId = cookId;
35                 idOfOrder = orderId;
36                 status = PizzaOrderStatus.DONE;
37         }
38
39         public Pizza() {
40                 super();
41         }
42
43         public static Pizza createPizzaFromPizzaOrder(PizzaOrder pizzaorder, int cookId) {
44                 return new Pizza(pizzaorder.getId(), pizzaorder.getPizzaType(), cookId, pizzaorder.getOrderId());
45         }
46
47         @Override
48         public String toString() {
49                 return "Pizza [deliveryAgent=" + deliveryAgent + ", id=" + id + ", orderId=" + orderId + ", pizzaType=" + pizzaType
50                                 + ", status=" + status + ", cookId=" + cookId + "]";
51         }
52
53         @Override
54         public int getOrderId() {
55                 return getIdOfOrder();
56         };
57
58         @Override
59         public void setOrderId(Integer orderId) {
60                 idOfOrder = orderId;
61         };
62
63         public int getIdOfOrder() {
64                 return Util.getIntSafe(idOfOrder);
65         }
66
67         public void setIdOfOrder(Integer idOfOrder) {
68                 this.idOfOrder = idOfOrder;
69         }
70
71 }