CMSC446 Introduction To Design Patterns
Spring 2004
Project 1
Shopping Mall Project
Due Date: April 5, 2004
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.
- 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
- Enumeration stores() - returns an enumeration of the
stores in the mall
- void addStore(Store s) - add a store to the mall
- Store
- Abstract superclass for a store
- Notable Attributes:
- name - the name of the store
- id - unique ID for the store
- items - items available for sale in the store
- customers - the customers currently in the store
- observers - the observers of 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
- void addObserver(Osberver o) - add an observer
to the store
- 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:
- name - the name of the item
- id - 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
- void addItem(item) - add an item
to the shopping cart
- void removeItem(item) - remove an
item from the shopping 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 or Factory Method (or both!)
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!
- Composite
One way to utilize the Composite pattern is to sell combo items
in a store, such as a combo meal or a combo outfit.
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 - 55%
- 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 - 30%
- 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 cs446 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 cs446 project1
To remove a previously submitted file, type
submitrm cs446 project1 <filename>
Project Due Date
This project is due April 5, 2004. You have a one week, automatic,
grace period.
No project will be accepted after April 12, 2004.
NO EXCEPTIONS! NO EXCUSES!