Class Order


  • public class Order
    extends java.lang.Object
    The 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
      Client getClient()
      Returns the client of this order.
      java.time.LocalDate getOrderDate()
      Returns the order date of this order.
      int getOrderID()
      Returns the order ID of this order.
      boolean getOrderPaid()
      Returns true if this order has been paid for, false otherwise.
      java.util.ArrayList<ProductOnOrder> getProducts()  
      float getTotalPrice()  
      void setClient​(Client client)
      Sets the client of this order to the specified value.
      void setOrderID​(int orderID)
      Sets the order ID of this order to the specified value.
      void setOrderPaid​(boolean orderPaid)
      Sets whether this order has been paid for.
      void setTotalPrice​(float totalPrice)  
      java.lang.String toString()
      Returns a string representation of this order object.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • 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 order
        products - 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 the printOutProductList method of the controller object associated with this order.
        Overrides:
        toString in class java.lang.Object
        Returns:
        a string representation of this order object.