orderprocessing
Class Order

java.lang.Object
  extended byorderprocessing.Order
All Implemented Interfaces:
java.io.Serializable

public class Order
extends java.lang.Object
implements java.io.Serializable

This class represents a single order from a single customer.

Additionally, this class maintains a collection of all Orders.

See Also:
Serialized Form

Constructor Summary
Order(Customer customer, Address shipAddress, java.util.ArrayList orderedItems, CalculationCalendar orderDate)
          Create an Order for a particular customer and a sequence of items ordered
Order(Customer customer, Address shipAddress, BillingTerms billingTerms, java.util.ArrayList orderedItems, CalculationCalendar orderDate, CalculationCalendar requestedShippingDate, CalculationCalendar cancelDate)
          Create an Order for a particular customer and a sequence of items ordered
 
Method Summary
 Address billingAddress()
          Retrieve the billing address for this order's customer
 BillingTerms billingTerms()
          Retrieve the billing terms for this order
 void billingTerms(BillingTerms billingTerms)
          Assign new billing terms to this order
 CalculationCalendar cancelDate()
          Retrieve the last date on which the customer may cancel the order
 void cancelOrder()
          Cancel this order
static void close(java.io.ObjectOutputStream out)
          Write out all the orders at the end of a run to the saved database
 Customer customer()
          Retrieve the customer for this order
 void display()
          Display this order on standard output (mostly for debugging)
static void dump()
          Show all of the orders on standard output
 boolean equals(java.lang.Object other)
           
 void format(java.io.BufferedWriter file)
          Format this order in a readable way and write on a stream
static void formatAll(java.io.BufferedWriter file)
          Format all known orders (not just outstanding ones) and print to a file
static Order get(java.lang.String key)
          Retrieve an order from its system assigned order number
 int hashcode()
           
 boolean isCancelled()
          Return whether this order has been cancelled or not
 java.lang.String key()
          Retrieve the order number for this order
static java.util.Iterator keys()
          Provide an iteration service over the order numbers that have been created
static void open(java.io.ObjectInputStream in)
          Read in all the orders at the beginning of a run from the saved database
 CalculationCalendar orderDate()
          Retrieve the date this order was created
 java.util.Iterator orderedItems()
          Provide an iteration service for the items ordered on this order
static java.util.Iterator orders()
          Provide an iteration service over all orders
 CalculationCalendar requestedShippingDate()
          Retrieve the date the customer would like the order shipped
 Address shippingAddress()
          Retrieve the shipping address for this order
 void shippingAddress(Address address)
          Give this order a new ship address
 int size()
          Retrieve the number of order items on this order
 java.lang.String toString()
           
 double total()
          return the extended total dollar value of this order
 boolean valid()
          Return whether this is a valid order or not
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Order

public Order(Customer customer,
             Address shipAddress,
             java.util.ArrayList orderedItems,
             CalculationCalendar orderDate)
Create an Order for a particular customer and a sequence of items ordered

Parameters:
customer - The customer ordering these items
shipAddress - The address the order should be shipped to.
orderedItems - A ArrayList of OrderItems representing the items ordered
orderDate - The date that this order was placed

Order

public Order(Customer customer,
             Address shipAddress,
             BillingTerms billingTerms,
             java.util.ArrayList orderedItems,
             CalculationCalendar orderDate,
             CalculationCalendar requestedShippingDate,
             CalculationCalendar cancelDate)
Create an Order for a particular customer and a sequence of items ordered

Parameters:
customer - The customer ordering these items
shipAddress - The Shipping Address if different from the customer's default
billingTerms - The billing terms for order if not the customer's default.
orderedItems - A ArrayList of OrderItems representing the items ordered
orderDate - The date that this order was placed
requestedShippingDate - Requested shipping date by customer
cancelDate - Requested cancelation date for this order.
Method Detail

customer

public Customer customer()
Retrieve the customer for this order

Returns:
the customer

billingAddress

public Address billingAddress()
Retrieve the billing address for this order's customer

Returns:
the billing address

shippingAddress

public Address shippingAddress()
Retrieve the shipping address for this order

Returns:
the ship to address

orderedItems

public java.util.Iterator orderedItems()
Provide an iteration service for the items ordered on this order

Returns:
an iterator over the ordered items

size

public int size()
Retrieve the number of order items on this order

Returns:
the number of order items

orderDate

public CalculationCalendar orderDate()
Retrieve the date this order was created

Returns:
the order date

requestedShippingDate

public CalculationCalendar requestedShippingDate()
Retrieve the date the customer would like the order shipped

Returns:
the customer's requested ship date

cancelDate

public CalculationCalendar cancelDate()
Retrieve the last date on which the customer may cancel the order

Returns:
the order's cancelation date

valid

public boolean valid()
Return whether this is a valid order or not

Returns:
true if the order is valid

key

public java.lang.String key()
Retrieve the order number for this order

Returns:
the system generated order number

billingTerms

public BillingTerms billingTerms()
Retrieve the billing terms for this order

Returns:
the billing terms

isCancelled

public boolean isCancelled()
Return whether this order has been cancelled or not

Returns:
true if the order was cancelled

total

public double total()
return the extended total dollar value of this order

Returns:
the total value

cancelOrder

public void cancelOrder()
Cancel this order


billingTerms

public void billingTerms(BillingTerms billingTerms)
Assign new billing terms to this order

Parameters:
billingTerms - the new terms

formatAll

public static void formatAll(java.io.BufferedWriter file)
Format all known orders (not just outstanding ones) and print to a file

Parameters:
file - the stream to write onto

format

public void format(java.io.BufferedWriter file)
            throws java.io.IOException
Format this order in a readable way and write on a stream

Parameters:
file - the stream to write to
Throws:
java.io.IOException

shippingAddress

public void shippingAddress(Address address)
Give this order a new ship address

Parameters:
address - the new ship address

display

public void display()
Display this order on standard output (mostly for debugging)


equals

public boolean equals(java.lang.Object other)

hashcode

public int hashcode()

toString

public java.lang.String toString()

get

public static Order get(java.lang.String key)
Retrieve an order from its system assigned order number

Parameters:
key - the order number of the desired order
Returns:
the order requested or null if none

close

public static final void close(java.io.ObjectOutputStream out)
                        throws java.io.IOException
Write out all the orders at the end of a run to the saved database

Parameters:
out - the Object stream to write to
Throws:
java.io.IOException

open

public static final void open(java.io.ObjectInputStream in)
                       throws java.io.IOException,
                              java.lang.ClassNotFoundException
Read in all the orders at the beginning of a run from the saved database

Parameters:
in - the stream to read from
Throws:
java.io.IOException
java.lang.ClassNotFoundException

orders

public static java.util.Iterator orders()
Provide an iteration service over all orders

Returns:
an iterator over the orders. The iterator returns Order objects.

keys

public static java.util.Iterator keys()
Provide an iteration service over the order numbers that have been created

Returns:
an iteration over the (String) order numbers

dump

public static void dump()
Show all of the orders on standard output