Class OrderItem


  • public class OrderItem
    extends java.lang.Object
    Order Item - one or more order items are assigned to one order, each item specifies a product and the amount. Furthermore an order item can carry a promotion discount.
    Author:
    Karl Eilebrecht
    • Method Detail

      • createOrderItem

        public static OrderItem createOrderItem​(CustomerOrder order,
                                                java.lang.String product,
                                                int amount,
                                                double pricePerUnit,
                                                double promotionDiscountPerc)
        Creates new order item. If the order already contains an item for the specified product a merge will take place.
        Parameters:
        order - the order this item belongs to
        product - ordered product
        amount - number of items
        pricePerUnit - price of one item
        promotionDiscountPerc - special promotion discount percentage
        Returns:
        valid order item
      • getProduct

        public java.lang.String getProduct()
        Returns the product this item carries
        Returns:
        product
      • getAmount

        public int getAmount()
        Returns the amount (number of units) this item carries
        Returns:
        amount
      • setAmount

        public void setAmount​(int amount)
        Sets the amount (number of units) to be ordered
        Parameters:
        amount - number of units
      • getPricePerUnit

        public double getPricePerUnit()
        Returns the unit price
        Returns:
        unit price
      • setPricePerUnit

        public void setPricePerUnit​(double pricePerUnit)
        Sets the unit price
        Parameters:
        pricePerUnit - price of one item
      • getPromotionDiscountPerc

        public double getPromotionDiscountPerc()
        Returns the optional promotion discount for this item
        Returns:
        promotion discount as percentage value
      • setPromotionDiscountPerc

        public void setPromotionDiscountPerc​(double promotionDiscountPerc)
        Sets the optional promotion discount for this item
        Parameters:
        promotionDiscountPerc - special promotion discount percentage
      • setOrder

        public void setOrder​(CustomerOrder order)
        Sets the order this item belongs to
        Parameters:
        order - related order
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object