|
1 | | -package coreapi; |
2 | | - |
3 | | -import java.util.Date; |
4 | | -import java.time.LocalDate; |
5 | | -/** |
6 | | - * The static factory to use in the creation of new order objects. |
7 | | - * @author Borja |
8 | | - * @author Mar�a |
9 | | - * @version 0.2 |
10 | | - * @see Order |
11 | | - */ |
12 | | -public class OrderFactory |
13 | | -{ |
14 | | - |
15 | | - // There is just this ONE number counter, which is incremental. |
16 | | - // It starts at 0 because the first registered order will have 0 as its identification number. |
17 | | - private static int orderCount = 0; |
18 | | - |
19 | | - /** |
20 | | - * Returns the current counter of created Orders. |
21 | | - * |
22 | | - * This is id number that will be assigned to the next Order created, |
23 | | - * which is unique for each and everyone of them. |
24 | | - * @return Returns the current unique id counter. |
25 | | - */ |
26 | | - public static int getOrderCount() |
27 | | - { |
28 | | - return orderCount; |
29 | | - } |
30 | | - |
31 | | - /** |
32 | | - * Returns a new instance of Order with a unique id. |
33 | | - * |
34 | | - * Sets the timestamp as the current time of execution. |
35 | | - * @param assignedCafeteria The cafeteria to which the new order pertains. |
36 | | - * @return The newly created instance of an order. |
37 | | - * @see Order |
38 | | - */ |
39 | | - public static Order createOrder(Cafeteria assignedCafeteria) |
40 | | - { |
41 | | - return createOrder(assignedCafeteria, LocalDate.now()); |
42 | | - } |
43 | | - |
44 | | - /** |
45 | | - * Returns a new instance of <code>Order</code> with a unique id. |
46 | | - * |
47 | | - * Sets the specified timestamp as the order's creation date. |
48 | | - * @param assignedCafeteria The cafeteria to which the new order pertains. |
49 | | - * @param creationDate The timestamp to assign to the order. |
50 | | - * @return The newly created instance of an order from the indicated date. |
51 | | - * @see Order |
52 | | - * @see Date |
53 | | - */ |
54 | | - public static Order createOrder(Cafeteria assignedCafeteria, LocalDate creationDate) |
55 | | - { |
56 | | - OrderImpl createdOrder = new OrderImpl(orderCount++, creationDate); |
57 | | - assignedCafeteria.registerOrder(createdOrder); |
58 | | - return createdOrder; |
59 | | - } |
60 | | -} |
| 1 | +package coreapi; |
| 2 | + |
| 3 | +import java.util.Date; |
| 4 | +import java.time.LocalDate; |
| 5 | +/** |
| 6 | + * The static factory to use in the creation of new order objects. |
| 7 | + * @author Borja |
| 8 | + * @author Maria |
| 9 | + * @version 0.2 |
| 10 | + * @see Order |
| 11 | + */ |
| 12 | +public class OrderFactory |
| 13 | +{ |
| 14 | + |
| 15 | + // There is just this ONE number counter, which is incremental. |
| 16 | + // It starts at 0 because the first registered order will have 0 as its identification number. |
| 17 | + private static int orderCount = 0; |
| 18 | + |
| 19 | + /** |
| 20 | + * Returns the current counter of created Orders. |
| 21 | + * |
| 22 | + * This is id number that will be assigned to the next Order created, |
| 23 | + * which is unique for each and everyone of them. |
| 24 | + * @return Returns the current unique id counter. |
| 25 | + */ |
| 26 | + public static int getOrderCount() |
| 27 | + { |
| 28 | + return orderCount; |
| 29 | + } |
| 30 | + |
| 31 | + /** |
| 32 | + * Returns a new instance of Order with a unique id. |
| 33 | + * |
| 34 | + * Sets the timestamp as the current time of execution. |
| 35 | + * @param assignedCafeteria The cafeteria to which the new order pertains. |
| 36 | + * @return The newly created instance of an order. |
| 37 | + * @see Order |
| 38 | + */ |
| 39 | + public static Order createOrder(Cafeteria assignedCafeteria) |
| 40 | + { |
| 41 | + return createOrder(assignedCafeteria, LocalDate.now()); |
| 42 | + } |
| 43 | + |
| 44 | + /** |
| 45 | + * Returns a new instance of <code>Order</code> with a unique id. |
| 46 | + * |
| 47 | + * Sets the specified timestamp as the order's creation date. |
| 48 | + * @param assignedCafeteria The cafeteria to which the new order pertains. |
| 49 | + * @param creationDate The timestamp to assign to the order. |
| 50 | + * @return The newly created instance of an order from the indicated date. |
| 51 | + * @see Order |
| 52 | + * @see Date |
| 53 | + */ |
| 54 | + public static Order createOrder(Cafeteria assignedCafeteria, LocalDate creationDate) |
| 55 | + { |
| 56 | + OrderImpl createdOrder = new OrderImpl(orderCount++, creationDate); |
| 57 | + assignedCafeteria.registerOrder(createdOrder); |
| 58 | + return createdOrder; |
| 59 | + } |
| 60 | +} |
0 commit comments