Class Order
- java.lang.Object
-
- Order
-
public class Order extends java.lang.ObjectThe Order class represents an order made by a client, including the order ID, date, client details, whether it has been paid or not, product quantity, total price and the products included in the order.
-
-
Constructor Summary
Constructors Constructor Description Order(Client client, java.util.ArrayList<ProductOnOrder> products)Constructs an order object with the specified client and list of products.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ClientgetClient()Returns the client of this order.java.time.LocalDategetOrderDate()Returns the order date of this order.intgetOrderID()Returns the order ID of this order.booleangetOrderPaid()Returns true if this order has been paid for, false otherwise.java.util.ArrayList<ProductOnOrder>getProducts()floatgetTotalPrice()voidsetClient(Client client)Sets the client of this order to the specified value.voidsetOrderID(int orderID)Sets the order ID of this order to the specified value.voidsetOrderPaid(boolean orderPaid)Sets whether this order has been paid for.voidsetTotalPrice(float totalPrice)java.lang.StringtoString()Returns a string representation of this order object.
-
-
-
Constructor Detail
-
Order
public Order(Client client, java.util.ArrayList<ProductOnOrder> products)
Constructs an order object with the specified client and list of products. The order ID is automatically generated as the current largest order ID plus one. The order date is set to the current date. The payment status is set to false. The product quantity is set to the size of the product list. The total price is calculated as the sum of the prices of all products in the list.- Parameters:
client- the client who made the orderproducts- the list of products ordered
-
-
Method Detail
-
getOrderID
public int getOrderID()
Returns the order ID of this order.- Returns:
- the order ID of this order.
-
setOrderID
public void setOrderID(int orderID)
Sets the order ID of this order to the specified value.- Parameters:
orderID- the new order ID of this order.
-
getOrderDate
public java.time.LocalDate getOrderDate()
Returns the order date of this order.- Returns:
- the order date of this order.
-
getClient
public Client getClient()
Returns the client of this order.- Returns:
- the client of this order.
-
setClient
public void setClient(Client client)
Sets the client of this order to the specified value.- Parameters:
client- the new client of this order.
-
getOrderPaid
public boolean getOrderPaid()
Returns true if this order has been paid for, false otherwise.- Returns:
- true if this order has been paid for, false otherwise.
-
setOrderPaid
public void setOrderPaid(boolean orderPaid)
Sets whether this order has been paid for.- Parameters:
orderPaid- true if this order has been paid for, false otherwise.
-
getTotalPrice
public float getTotalPrice()
-
setTotalPrice
public void setTotalPrice(float totalPrice)
-
getProducts
public java.util.ArrayList<ProductOnOrder> getProducts()
-
toString
public java.lang.String toString()
Returns a string representation of this order object. The returned string contains the order ID, order date, payment status, client ID, client name, total price, and a list of products in the order, including their ID, name, quantity, unit price, and total price. The shopping list is obtained by calling theprintOutProductListmethod of the controller object associated with this order.- Overrides:
toStringin classjava.lang.Object- Returns:
- a string representation of this order object.
-
-