Skip to content

Commit 4f9afe2

Browse files
Fixed errors
1 parent 8433d12 commit 4f9afe2

File tree

2 files changed

+65
-65
lines changed

2 files changed

+65
-65
lines changed
Lines changed: 60 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,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 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+
}

api/src/main/java/coreapi/OrderService.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,21 @@ public OrderService() {}
2323

2424
/**
2525
* Adds the indicated amount of product to the order passed as an argument.
26-
* @param cafet The Cafeteria related to the order.
26+
* @param coffe The Cafeteria related to the order.
2727
* @param ord The order to add the product to.
2828
* @param productId The id of the product to add to the order.
2929
* @param quantity The quantity of product to add to the order.
3030
* @throws InsufficientStockException If there isn't enough stock of the product.
3131
*/
32-
public void addProductToOrder(Cafeteria cafet, OrderImpl ord, int productId, int quantity)
32+
public void addProductToOrder(Cafeteria coffe, OrderImpl ord, int productId, int quantity)
3333
throws InsufficientStockException
3434
{
3535
Product prod = ProductCatalog.Instance().getProduct(productId);
36-
if(cafet.getAvailableProducts().contains(prod))
36+
if(coffe.getAvailableProducts().contains(prod))
3737
{
38-
if(quantity > 0 && cafet.getProductQuantity(prod) >= quantity)
38+
if(quantity > 0 && coffe.getProductQuantity(prod) >= quantity)
3939
{
40-
cafet.removeStock(prod, quantity);
40+
coffe.removeStock(prod, quantity);
4141
ord.addProduct(productId, quantity);
4242
}
4343
else

0 commit comments

Comments
 (0)