Skip to content

Commit dba88d5

Browse files
Own exceptions
2 parents cb28537 + 9a67192 commit dba88d5

File tree

1 file changed

+59
-7
lines changed

1 file changed

+59
-7
lines changed

src/main/java/coreapi/OrderService.java

Lines changed: 59 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,16 @@ public OrderService() {}
4545
* PRECONDITION:Receive an order and an id of a existing product, plus a positive quantity
4646
* POSTCONDITION: Add the product with the indicated quantity to the order
4747
*/
48-
public void addProductToOrder(Cafeteria coffe, OrderImpl ord, int productId, int q) throws InsufficientStock, ExistenceInTheBasket
48+
/**
49+
* Add a quantity of product to an order of a cafeteria.
50+
* @param coffe the Cafeteria which stock the different orders.
51+
* @param ord the order which stock the different products and the quantities.
52+
* @param productId the id of the product which will be add to the order.
53+
* @param q the quantity of the product.
54+
* @throws If the product is already in the basket
55+
* @throws If there isn't enough stock of the product
56+
*/
57+
public void addProductToOrder(Cafeteria coffe, OrderImpl ord, int productId, int q)throws InsufficientStock, ExistenceInTheBasket
4958
{
5059
Product prod = ProductCatalog.Instance().getProduct(productId);
5160
if(ord.containsProduct(productId))
@@ -73,7 +82,16 @@ public void addProductToOrder(Cafeteria coffe, OrderImpl ord, int productId, int
7382
* PRECONDITION:Receive an order and an id of a existing product, plus a positive quantity
7483
* POSTCONDITION: Modify the quantity of the product indicated in the order
7584
*/
76-
public void modifyProductQuantity(Cafeteria coffe, OrderImpl ord, int productId, int q) throws InsufficientStock, ExistenceInTheBasket
85+
/**
86+
* Modify the quantity of a product in an order
87+
* @param coffe the Cafeteria which stock the different orders.
88+
* @param ord the order which stock the different products and the quantities.
89+
* @param productId the id of the product which will be add to the order.
90+
* @param q the quantity of the product.
91+
* @throws If there isn't enough stock of the product
92+
* @throws If the product isn't in the basket
93+
*/
94+
public void modifyProductQuantity(Cafeteria coffe, OrderImpl ord, int productId, int q)throws InsufficientStock, ExistenceInTheBasket
7795
{
7896
Product prod = ProductCatalog.Instance().getProduct(productId);
7997

@@ -98,7 +116,14 @@ public void modifyProductQuantity(Cafeteria coffe, OrderImpl ord, int productId,
98116
* PRECONDITION:Receive an order and an id of a existing product, plus a positive quantity
99117
* POSTCONDITION:Eliminate the indicated amount of the product
100118
*/
101-
public void removeProductFromOrder(OrderImpl ord, int productId, int q) throws ExistenceInTheBasket, InsufficientStock
119+
/**
120+
* @param ord the order which stock the different products and the quantities.
121+
* @param productId the id of the product which will be add to the order.
122+
* @param q the quantity of the product.
123+
* @throws If the quantity to remove is bigger than the quantity which is stock in the order
124+
* @throws If the product isn't in the basket
125+
*/
126+
public void removeProductFromOrder(OrderImpl ord, int productId, int q)throws ExistenceInTheBasket, InsufficientStock
102127
{
103128
int quantbasket = ord.checkProductQuantity(productId);
104129
if(ord.containsProduct(productId))
@@ -124,7 +149,10 @@ public void removeProductFromOrder(OrderImpl ord, int productId, int q) throws E
124149
* PRECONDITION:Receive an order
125150
* POSTCONDITION: Assign the status to the order
126151
*/
127-
public void OrderStatus_InKitchen(OrderImpl ord) throws StatusException
152+
/**
153+
*
154+
*/
155+
public void OrderStatus_InKitchen(OrderImpl ord)throws StatusException
128156
{
129157
//There must be products in the basket and the order be in the open state
130158
if(!ord.getProducts().isEmpty() && ord.getStatus() == OrderStatus.OPEN)
@@ -141,7 +169,13 @@ public void OrderStatus_InKitchen(OrderImpl ord) throws StatusException
141169
* PRECONDITION:Receive an order
142170
* POSTCONDITION: Assign the status to the order
143171
*/
144-
public void OrderStatus_Delivered(OrderImpl ord) throws StatusException
172+
/**
173+
* Returns the current counter of created Orders.
174+
* This is id number that will be assigned to the next Order created,
175+
* which is unique for each and everyone of them.
176+
* @return the current unique id counter.
177+
*/
178+
public void OrderStatus_Delivered(OrderImpl ord)throws StatusException
145179
{
146180
//The state must be in the kitchen to be delivered
147181
if(ord.getStatus() == OrderStatus.IN_KITCHEN)
@@ -157,7 +191,13 @@ public void OrderStatus_Delivered(OrderImpl ord) throws StatusException
157191
* PRECONDITION:Receive an order
158192
* POSTCONDITION: Assign the status to the order
159193
*/
160-
public void OrderStatus_Payed(OrderImpl ord) throws StatusException
194+
/**
195+
* Returns the current counter of created Orders.
196+
* This is id number that will be assigned to the next Order created,
197+
* which is unique for each and everyone of them.
198+
* @return the current unique id counter.
199+
*/
200+
public void OrderStatus_Payed(OrderImpl ord)throws StatusException
161201
{
162202
//The state must be delivered or in the kitchen in order to be paid
163203
if(ord.getStatus() == OrderStatus.IN_KITCHEN || ord.getStatus() == OrderStatus.DELIVERED)
@@ -175,7 +215,13 @@ public void OrderStatus_Payed(OrderImpl ord) throws StatusException
175215
* PRECONDITION:Receive an order
176216
* POSTCONDITION: Assign the status to the order
177217
*/
178-
public void OrderStatus_Finished(OrderImpl ord) throws StatusException
218+
/**
219+
* Returns the current counter of created Orders.
220+
* This is id number that will be assigned to the next Order created,
221+
* which is unique for each and everyone of them.
222+
* @return the current unique id counter.
223+
*/
224+
public void OrderStatus_Finished(OrderImpl ord)throws StatusException
179225
{
180226
// The state must be charged in order to be finalized
181227
if(ord.getStatus() == OrderStatus.PAYED)
@@ -195,6 +241,12 @@ public void OrderStatus_Finished(OrderImpl ord) throws StatusException
195241
* PRECONDITION: Receive a date
196242
* POSTCONDITION: Return the total of all orders for the date entered.
197243
*/
244+
/**
245+
* Returns the current counter of created Orders.
246+
* This is id number that will be assigned to the next Order created,
247+
* which is unique for each and everyone of them.
248+
* @return the current unique id counter.
249+
*/
198250
public BigDecimal getDailyRegister(Cafeteria coffe, Date date)
199251
{
200252
BigDecimal dailyRegister = BigDecimal.ZERO;

0 commit comments

Comments
 (0)