Class AmountablePrice<T extends IAmountable>

  • Type Parameters:
    T - IAmountable implementation that is is collected hereby called item

    public class AmountablePrice<T extends IAmountable>
    extends BaseAmountable<T>
    This class defines the amounted price of an IWare object. Each object in the real world has hits unique price. Since no instances of the objects are used but only one reference the price information gets lost. The amountable price tracks the average price of all amounted objects
    Author:
    Andi Hotz, (c) Sahits GmbH, 2011 Created on Nov 20, 2011
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private javafx.beans.property.DoubleProperty sum
      Total price of all amounted items
    • Constructor Summary

      Constructors 
      Constructor Description
      AmountablePrice()  
      AmountablePrice​(int amount, double totalPrice)
      Constructor initalizing the amountablePrice with an amount and average price.
    • Field Detail

      • sum

        private final javafx.beans.property.DoubleProperty sum
        Total price of all amounted items
    • Constructor Detail

      • AmountablePrice

        public AmountablePrice()
      • AmountablePrice

        public AmountablePrice​(int amount,
                               double totalPrice)
        Constructor initalizing the amountablePrice with an amount and average price. This constructor is mainly inteded for testing to avoid the hassle with the add method.
        Parameters:
        amount - represented by this.
        totalPrice - total price of the complete amount
    • Method Detail

      • getAVGPrice

        public int getAVGPrice()
        Retrieve the average price of one item
        Returns:
        average price per item
      • avgPriceProperty

        public javafx.beans.binding.NumberBinding avgPriceProperty()
      • add

        public void add​(int amount,
                        int avgPrice)
        Add a number items
        Parameters:
        amount - number of the items to be added
        avgPrice - average price of one item that is added
      • remove

        public void remove​(int amount)
        Remove a number of items
        Overrides:
        remove in class BaseAmountable<T extends IAmountable>
        Parameters:
        amount - of items to be removed
      • getSum

        public double getSum()
        Get the total cum of the amount.
        Returns:
        total price of all items.