orderprocessing
Class OrderProcessor
java.lang.Object
|
+--orderprocessing.OrderProcessor
- public class OrderProcessor
- extends java.lang.Object
This class accepts and fulfills orders from customers. It can create an order
from appropriate information and it can create an invoice from an order.
It also maintains the logic for opening and closing the object database as the
program starts and quits.
It also does some writing to System.out that would better be handled by dialogs.
Method Summary |
static void |
close(java.lang.String filename)
close the database at the end of processing. |
static java.lang.String |
databaseName()
The name of the database file |
Invoice |
generateInvoice(Order order)
Generate an invoice from an order. |
static void |
main(java.lang.String[] args)
This method is used only to initialize the database to empty after a
catastrophic failure in which the data must all be rebuild from external
data.It will leave you with an empty database. |
Order |
newOrder(java.lang.String customer,
java.lang.String terms,
java.lang.String shipping,
java.util.ArrayList items,
CalculationCalendar orderDate,
CalculationCalendar requestedShipDate,
CalculationCalendar cancelDate)
Generate an order object from string data sent to it. |
static void |
open(java.lang.String filename)
Open the database at the beginning of processing by reading it into
memory from the saved version. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
orderProcessor
public static OrderProcessor orderProcessor
newOrder
public Order newOrder(java.lang.String customer,
java.lang.String terms,
java.lang.String shipping,
java.util.ArrayList items,
CalculationCalendar orderDate,
CalculationCalendar requestedShipDate,
CalculationCalendar cancelDate)
- Generate an order object from string data sent to it. This method acts
like a factory for Orders.
- Parameters:
customer
- String with customer number (C5001, C5001,...)shipping
- The shipping address normally associated with this customer (will change)items
- An ArrayList of strings each of which is a quantity, itemnumber, price, and.
description. There is a tide ~ separation between the fields.orderDate
- The date of this order.requestedShipDate
- the date shipment is requested (Order date + 7days).cancelDate
- the date the order should be cancelled if not yet shipped.- Returns:
- an Order for these items or null if the customer is invalid.
Note that this is a Factory Method (pattern) for Order objects
generateInvoice
public Invoice generateInvoice(Order order)
- Generate an invoice from an order.
- Parameters:
order
- An order previously placed by a customer.- Returns:
- An Invoice for items that can be shipped.
close
public static void close(java.lang.String filename)
- close the database at the end of processing. Write it to the
saved version. Must be compatible with open.
- Parameters:
filename
- the name of the file to write onto
open
public static void open(java.lang.String filename)
- Open the database at the beginning of processing by reading it into
memory from the saved version. Must be compatible with close.
- Parameters:
filename
- the name of the file to read from
databaseName
public static java.lang.String databaseName()
- The name of the database file
- Returns:
- the name of the file
main
public static void main(java.lang.String[] args)
- This method is used only to initialize the database to empty after a
catastrophic failure in which the data must all be rebuild from external
data.It will leave you with an empty database.