CMSC491D Design Patterns In Java
Fall 2000
Project 1
Shopping Mall Project
Due Date: November 13, 2000
Project Description
In this project, you will be implementing a simple shopping mall in
Java. The mall will provide a soothing shopping experience for your
customers, while at the same time allowing you to explore the wonderful
world of design patterns!
The class diagram which provides the framework for the shopping mall
is as follows:
Here's a brief description of each class:
- Mall
- The mall itself. Either an applet or application.
The mall performs the creation of a set of different stores,
such as a book store, a shoe store, an electronic games
store, etc. The mall greets an arriving customer and allows
the customer to shop at the mall.
Some of the things a customer can do at the mall are:
- Get a list of available stores
- Get a shopping cart
- Enter a store
- Get of list of items available for sale at the store
- Add items to the shopping cart
- Proceed to checkout and purchase the items
- Notable Attributes:
- name - the name of the mall
- stores - a collection of stores of different types
- customers - the customers currently in the mall
- Possible Methods:
- void enter(Customer c) - customer c enters the mall
- void exit(Customer c) - customer c exits the mall
- ShoppingCart getShoppingCart - returns an empty shopping cart
- Enumeration customers() - returns an enumeration of the
customers in the mall
- void checkout(shoppingCart cart) - checkout and purchase the
items in the shopping cart
- Store
- Abstract superclass for a store
- Notable Attributes:
- name - the name of the store
- storeId - unique ID for the store
- items - items available for sale in the store
- customers - the customers currently in the store
- Possible Methods:
- abstract void enter(Customer c) - customer c enters the store
- abstract void exit(Customer c) - customer c exits the store
- Enumeration customers() - returns an enumeration of the
customers in the store
- Enumeration items() - returns an enumeration of the items
available for sale in the store
- abstract void addToCart(shopingCart, item) - add an item
to the shopping cart
- abstract void removeFromCart(shopingCart, item) - remove an
item from the shopping cart
- BookStore
- A possible subclass of Store
- ShoeStore
- A possible subclass of Store
- GameStore
- A possible subclass of Store
- Item
- An item for sale in a store
- Notable Attributes:
- itemName - the name of the item
- itemId - unique ID for the item
- storeId - the ID of the store from which the item came
- price - the price of the item
- Customer
- A customer!
- Notable Attributes:
- name - the name of the customer
- shoppingCart - the shopping cart being used by the customer
- store - the store the customer is currently in
- ShoppingCart
- A shopping cart for the customer
- Notable Attributes:
- items - items currently in the shopping cart
- Possible Methods:
- Enumeration items() - returns an enumeration of the items
currently in the cart
Note that required accessors and mutators are not listed in the above for
the sake of brevity.
Project Requirements
Use the above framework to write a working version of the
shopping mall.
Your project must have at least one customer, three stores and five items
for sale at each store.
Implement the user interface any way you like, either textual or graphical.
Your project must implement the following design patterns:
- Iterator
This one is easy. Methods that return an Enumeration demonstrate the
Iterator pattern.
- Abstract Factory with Factory Methods
Create all stores using factories.
- Singleton
Allow only one instance of any factory type you create.
- Observer
All stores should be observable objects. In particular, a customer
should be able to be notified whenever a new item has been added
for sale at a store. Demonstrate this pattern by having one or more
customers register for such notifications with one or more stores.
NOTE: The methods required to implement this pattern are not
specified above!
Feel free to use any other patterns you feel appropriate.
Your project code must also be well documented and use a reasonable
indentation style. In particular, places where design patterns are
implemented should be noted in the code.
Finally, a short report, no more than five pages in length, should be
submitted describing your use of design patterns in your project.
Please name the report file Project1.txt. Please submit this report
in text form only!
Project Grading
Your project will be graded according to the following criteria:
- Program Correctness - 60%
- The program performs all of its required functions properly.
- The program has no bugs.
- The program handles appropriate error conditions properly.
- The program operates with reasonable efficiency.
- Proper implementation of all required design patterns - 25%
- Coding Style - 10%
- Good, professional documentation.
- Good readability and understandability.
- Proper use of indentation to highlight function flow control.
- Proper use of blank lines to highlight distinct sections of a function.
- Project Report - 5%
As in all your work, NO COPYING OR PLAGIARISM. If such is
detected, no credit for the project will be given and appropriate
actions for academic dishonesty will be taken.
Project Submission
You must submit the following:
- All source files.
- All class files.
- Any makefile, if used.
- Your report file, Project1.txt
Submit all of the above using the submit program. To submit, you type
submit cs491d project1 <filenamelist>
where filenamelist is a list of one or more files. You can submit a
file as often as you like; the latest file submitted overwrites any
previous submissions. To list the names of the files you have submitted,
type
submitls cs491d project1
To remove a previously submitted file, type
submitrm cs491d project1 <filename>
Project Due Date
This project is due November 13, 2000. You have a one week, automatic,
no-need-for-a-lame-excuse grace period.
No project will be accepted after November 20, 2000.
NO EXCEPTIONS! NO EXCUSES!