FileDocCategorySizeDatePackage
PurchaseOrder.javaAPI DocExample2268Fri Mar 01 11:27:30 GMT 2002javajaxb.po

PurchaseOrder

public class PurchaseOrder extends Object

The PurchaseOrder class represents a complete PO within an application.

Fields Summary
protected List
orderList
The list of {@link Order} objects
Constructors Summary
public PurchaseOrder()

Initialize storage.

        this(new LinkedList());
    
public PurchaseOrder(List orderList)

This will create the PO with a predefined list of {@link Order} objects.

param
orderList the list of orders.

        if (orderList != null) {
            this.orderList = orderList;
        } else {
            this.orderList = new LinkedList();
        }
    
Methods Summary
public voidaddOrder(Order order)

This will add a new {@link Order} to this PO.

param
order the new Order to add.

        orderList.add(order);
    
public java.util.ListgetOrderList()

This will return the current list of orders.

return
List - list of orders.

        return orderList;
    
public floatgetTotalPrice()

This will calculate the total cost for this PO

return
float - the total price for this PO

        if (orderList == null) {
            return 0;
        }
        
        float totalPrice = 0;
        for (Iterator i = orderList.iterator(); i.hasNext(); ) {
            Order order = (Order)i.next();
            totalPrice += order.getStock().getQuantity() * order.getPurchasePrice();
        }
        return totalPrice;
    
public voidsetOrderList(java.util.List orderList)

This will set the list of orders. It also replaces any existing orders with the supplied list.

param
orderList list of orders.

        this.orderList = orderList;