Programming for the WWW G22.3033-009

Home
Final Grades
grades
Class Description
Slides and code
Homework
Schedule
Books
Class Mailing List
Contact Information
Req'd Downloads
Links
midterm exam
Final Exam Structure

Note: Changes have been highlighted

Officially released! (09-28-2002)

Homework Assignment #1
Homework Due:
October 14, 2002

Create a simulated online bookstore we'll call "Greenwich Village Books" or "GVBooks".

Business Problem:

Create a system that is a simple electronic bookstore application, The ability to select books and order them online. Multiple customers can have information records in the system. One user at a time can use the system. Orders will be saved to disk.

Actors:

bulletCustomer

Use Cases:

UC001. Manage Customer Record - TUCBW (The Use Case Begins When) the Customer is adding or updating a customer information record. The customer can add/update the following information: Name, Address, City, State, Zip, Phone, Email, Credit Card # and expiration.

UC002. Browse Book List - TUCBW (The Use Case Begins When) the Customer browsing a list of books sold through GVB. The Customer browses a  a list of books on the screen. The list is shown in a scrolling list box. The book title, ISBN number, Price and Quantity in Stock are shown for each book.

UC003. Select and Purchase Books - TUCBW the Customer browsing a list of books sold through GVB (see UC001). The Customer selects one or more books. They enter a quantity. They are not allowed to enter more quantity than are in stock. The Customer pressed a button to "check out". The subtotal of selected nooks is calculated and displayed. Tax is calculated (use 8.5%). The shipping is calculated (use $2.00 per book). Then the Customer enters they name, address, phone, email, credit card # and credit card expiration.

 

Functional Requirements: You must create a user interface that is written using Java Swing. 
 It should have the following dialogs and support the appropriate functionality for each dialog.

bulletManage Customer Info
bulletCreate New Order

Design requirements:

Class diagrams:

Customer
---------------------------------------------------------------------------------------------------
private String firstName;
private String lastName;
private String phone;
private String address;
private String city;
private String state;
private long zipcode;
private String emailAddress;
private long customerID;
---------------------------------------------------------------------------------------------------
static long NextCustomerID =1;
static final String CUSTOMER_FIELD_DELIMITER ="|";
public Customer(String firstName, String lastName,  String phone, String address, String city,
                              String state, long zipcode, String emailAddress)
public String toString()
public String toStringFormatFileRecord()
boolean saveCustomerToFile(String fileToSaveTo)
boolean loadCustomerFromFile(String fileToLoad)
public static void main(String[] args)
 

Text Box: Customer
---------------------------------------------------------------------------------------------------
private String firstName; 
private String lastName; 
private String phone; 
private String address; 
private String city; 
private String state; 
private long zipcode; 
private String emailAddress; 
private long customerID;
---------------------------------------------------------------------------------------------------
static long NextCustomerID =1;
static final String CUSTOMER_FIELD_DELIMITER ="|";
public Customer(String firstName, String lastName,  String phone, String address, String city,
                              String state, long zipcode, String emailAddress)
public String toString()
public String toStringFormatFileRecord()
boolean saveCustomerToFile(String fileToSaveTo) 
boolean loadCustomerFromFile(String fileToLoad) 
public static void main(String[] args)

 

 

 

 

 

 

 

 

 

 

 

 

Item
------------------------------------------------------------------------------------------------------------------
protected String title;
protected String ISBN;
protected String author;
protected String publisher;
protected double price;
public static final String TO_STRING_DELIMITER = "|";
------------------------------------------------------------------------------------------------------------------
public Item(String title, String ISBN, String author, String publisher, double price)
public String toString()
public String toStringFormatFileRecord()
String getAuthor()
String getTitle()
double getPrice()
String getISBN()
String getPublisher()
 

Text Box: Item
------------------------------------------------------------------------------------------------------------------
protected String title; 
protected String ISBN; 
protected String author; 
protected String publisher; 
protected double price; 
public static final String TO_STRING_DELIMITER = "|";
------------------------------------------------------------------------------------------------------------------
public Item(String title, String ISBN, String author, String publisher, double price)
public String toString()
public String toStringFormatFileRecord() 
String getAuthor() 
String getTitle()
double getPrice()
String getISBN() 
String getPublisher()

 

 

 

 

 

 

 

 

 

 

 

 

POItem extends Item
---------------------------------------------------------------------------------------------------------------------------------
private long quantityOrdered;
---------------------------------------------------------------------------------------------------------------------------------
public POItem(String title, String ISBN, String author, String publisher, double price,
                          long quantityOrdered)
public String toString()
public String toStringFormatFileRecord()
long    getQuantityOrdered()
boolean setQuantityOrdered(long quantityToOrder)
 

Text Box: POItem extends Item
---------------------------------------------------------------------------------------------------------------------------------
private long quantityOrdered; 
---------------------------------------------------------------------------------------------------------------------------------
public POItem(String title, String ISBN, String author, String publisher, double price,
                          long quantityOrdered)
public String toString()
public String toStringFormatFileRecord() 
long    getQuantityOrdered()
boolean setQuantityOrdered(long quantityToOrder)

 

 

 

 

 

 

 

 

InventoryItem extends Item
---------------------------------------------------------------------------------------------------------------------------------
private long quantityInStock;
private long quantityOnOrder;
---------------------------------------------------------------------------------------------------------------------------------
public InventoryItem(String title, String ISBN, String author, String publisher, double price,
                                    long quantityInStock, long quantityOnOrder)
public String toString()
public String toStringFormatFileRecord()
long getQuantityInStock()
long getQuantityOnOrder()
long removeQuantityFromStock(long quantityToRemove)
long addQuantityToStock(long quantityToAdd)
 

Text Box: InventoryItem extends Item 
---------------------------------------------------------------------------------------------------------------------------------
private long quantityInStock; 
private long quantityOnOrder;
---------------------------------------------------------------------------------------------------------------------------------
public InventoryItem(String title, String ISBN, String author, String publisher, double price,
                                    long quantityInStock, long quantityOnOrder)
public String toString()
public String toStringFormatFileRecord()
long getQuantityInStock()
long getQuantityOnOrder()
long removeQuantityFromStock(long quantityToRemove)
long addQuantityToStock(long quantityToAdd)

 

 

 

 

 

 

 

 

 

 

 

PO
---------------------------------------------------------------------------------------------------------------------------------
//max PO of 100 items
static public POItem[] POItemsArray = new POItem[100];
static private int NextElementToFill=0;
private int iterationIndex =0;
private String fileNameForPO;
static private String POFileDelimiter =POItem.TO_STRING_DELIMITER;
---------------------------------------------------------------------------------------------------------------------------------
public PO()
static int GetNumberOfItemsInPO()
boolean removePOItem( POItem itemToRemove)
boolean addItemToPO(POItem itemToAdd)
POItem getFirstItem()
POItem getNextItem()
void setFileNameForPO(String newFileName)
boolean loadPOFromFile()
boolean loadPOFromFile(String fileToLoad)
boolean savePOToFile()
boolean savePOToFile(String fileToSaveTo)
public static void main(String[] args)
 

Text Box: PO
---------------------------------------------------------------------------------------------------------------------------------
//max PO of 100 items
static public POItem[] POItemsArray = new POItem[100];
static private int NextElementToFill=0;
private int iterationIndex =0;
private String fileNameForPO; 
static private String POFileDelimiter =POItem.TO_STRING_DELIMITER;
---------------------------------------------------------------------------------------------------------------------------------
public PO()
static int GetNumberOfItemsInPO()
boolean removePOItem( POItem itemToRemove)
boolean addItemToPO(POItem itemToAdd)
POItem getFirstItem()
POItem getNextItem()
void setFileNameForPO(String newFileName)
boolean loadPOFromFile()
boolean loadPOFromFile(String fileToLoad)
boolean savePOToFile()
boolean savePOToFile(String fileToSaveTo)
public static void main(String[] args)

 

 

 

 

 

 

 

 

 

Inventory
---------------------------------------------------------------------------------------------------------------------------------
//max inventory of 100 items
static public InventoryItem[] InventoryItemsArray = new InventoryItem[100];
static private int NextElementToFill=0;
private int iterationIndex =0;
---------------------------------------------------------------------------------------------------------------------------------
static private String InventoryFileDelimiter =InventoryItem.TO_STRING_DELIMITER;
public Inventory()
static int GetNumberOfItemsInInventory()
boolean removeItemFromInventory(long quantityToRemove, InventoryItem itemToRemove)
boolean addItemToInventory(long quantityToAdd, InventoryItem itemToAdd)
InventoryItem getFirstItem()
InventoryItem getNextItem()
boolean loadInventoryFromFile(String fileToLoad)
boolean saveInventoryToFile(String fileToSaveTo)
public static void main(String[] args)

 

Text Box: Inventory
---------------------------------------------------------------------------------------------------------------------------------
//max inventory of 100 items
static public InventoryItem[] InventoryItemsArray = new InventoryItem[100];
static private int NextElementToFill=0;
private int iterationIndex =0;
---------------------------------------------------------------------------------------------------------------------------------
static private String InventoryFileDelimiter =InventoryItem.TO_STRING_DELIMITER;
public Inventory()
static int GetNumberOfItemsInInventory()
boolean removeItemFromInventory(long quantityToRemove, InventoryItem itemToRemove)
boolean addItemToInventory(long quantityToAdd, InventoryItem itemToAdd)
InventoryItem getFirstItem()
InventoryItem getNextItem()
boolean loadInventoryFromFile(String fileToLoad)
boolean saveInventoryToFile(String fileToSaveTo)
public static void main(String[] args)

 

 

 

 

 

 

 

 

 

 

 

 

 

Files:

inventory.txt

customer.1.txt

po.1.1.txt

 

Explicit Homework Requirements - READ THESE FOR SURE!

1.) This must be a Java SWING application. You may use JDialogs, JFrame, JMenus whatever visual components you wish. I suggest JDialogs because they are simple to create and use if your new to swing.

2) It must support a single user at a time (not be multiuser quite yet).

3) It must store the users name, address, phone, email, credit card information as a text file. These files should have the naming convention "Customer.CustomerID.txt". They should be stored as human readable text. They should be fields separated by a '|' (pipe symbol character).
Example:
                "1|Logan|Poelman|212-217-2487|100 President Street|Brooklyn|NY|11213|poelman@cs.nyu.edu|"
 
               CustomerID | FirstName | LastName | Phone | Address | City | State | Zipcode | email |

See the file "customer.1.txt" for an example file.

4) Book inventory must be stored as a Java readable/ human readable text file. It should be multiple inventory items in the file. The separator is the '|'.
Example:
               "Learning Java|0-596-00285-8|Niemeyer & Knudsen|O'Reilly|44.95|50|10|"

              Title  | ISBN | Author | Publisher | Price | Quantity In Stock | Quantity on Order |
 
See the "inventory.txt" file in the homework directory

5) The design must include the following classes (or an equivalent and better design, if you choose):

bulletCustomer
bulletItem
bulletInventoryItem
bulletPOItem
bulletPO
bulletInventory
bulletCustomerInfoDialog
bulletCustomerOrderDialog
bulletFileIOUtil

6) I should be able to:

bulletCreate a new CustomerInfo file and save it by pressing the Save button
bulletCreate a new Order by pressing the Order button which spawns a modal CustomerOrderDialog.
bulletSelect one or more titles from the Inventory List, enter a quantity, press the Add To Shopping Cart Button
and they should appear in the Order List.
bulletI should then be able to press the Submit Order  button and they would be written to disk
as a file named as follows "po.customerid.poid.txt", see "po.1.1.txt" for an example
example:
      po.1.231.txt    //customer id =1, po id = 231
      po.1.1.txt      //customer id =1, po id = 1
      po.200.1.txt    //customer id =200, po id = 1

Then the dialog would close and return me to the CustomerInfo dialog
bulletOr I should be able to press the Cancel Order and the CustomerOrderDialog would close and return me
to CustomerInfo dialog
bulletIf I press the Exit button the CustomerInfo dialog should close.

7) Application data files should be default be saved to a directory "homework/homework1/" files. (Hardcode it if you must)

8) You must create three different customers  and submit them with your application (as data saved in the data files). You must MAKE up the information about the customers.

8) You must create three different customer orders for different books and submit them with your application (as data saved in the data files). You must MAKE up the information about the orders.

9) You must zip up your complete application directory. Saving the subdirectory information in the zip file. Alternately you can create a java jar file with the java files and the class files in it.  Email the zip file to your assigned TA.

 

Hints on how to build the application:

Note: you do not have to follow this design. I have put it in here to help make this
assignment easier to understand and accomplish.

What my dialog consists of in the editor:

CustomerInfoDialog in the editor:

 

Pressing the Save button writes the data to a file specified by the File Name text field.

 

 

 

 

CustomerOrderDialog:

 

 

CustomerOrderDialog

Pressing Submit saves the order to disk and closes the Dialog.

Home | Final Grades | grades | Class Description | Slides and code | Homework | Schedule | Books | Class Mailing List | Contact Information | Req'd Downloads | Links | midterm exam | Final Exam Structure

 Copyright Poelman & Associates, Inc. (c) 2002 
For problems or questions regarding this web contact [ClassWebEmail].
Last updated: 11/05/02.