design pattern question

7
CT070-3-3 Design Patterns Individual Assignment Page 1 of 7 Weightage The coursework is 50% of the assessment for the module. Learning Outcomes: On successful completion of this assessment, the student should be able to: 1. Apply design patterns appropriately in realistic applications using an object oriented programming language. 2. Critically evaluate an example implementation of design patterns in a programming language. In this assignment, 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: Level 3 Asia Pacific University of Technology and Innovation 2013

Upload: ashi-sharma

Post on 21-Oct-2015

7 views

Category:

Documents


1 download

DESCRIPTION

about patterns in java

TRANSCRIPT

Page 1: design pattern question

CT070-3-3 Design Patterns Individual Assignment Page 1 of 4

Weightage The coursework is 50% of the assessment for the module.

Learning Outcomes:

On successful completion of this assessment, the student should be able to: 1. Apply design patterns appropriately in realistic applications using an object

oriented programming language.2. Critically evaluate an example implementation of design patterns in a

programming language.

In this assignment, 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:

Level 3 Asia Pacific University of Technology and Innovation 2013

Page 2: design pattern question

CT070-3-3 Design Patterns Individual Assignment Page 2 of 4

Here's a brief description of each class:

Mall o 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

o Notable Attributes: name - the name of the mall stores - a collection of stores of different types customers - the customers currently in the mall

o 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

o Abstract superclass for a store o 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

o 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

o A possible subclass of Store ShoeStore

o A possible subclass of Store GameStore

o A possible subclass of Store Level 3 Asia Pacific University of Technology and Innovation 2013

Page 3: design pattern question

CT070-3-3 Design Patterns Individual Assignment Page 3 of 4

Item o An item for sale in a store o 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 o A customer! o 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 o A shopping cart for the customer o Notable Attributes:

items - items currently in the shopping cart o 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.

Assignment Requirements

a. Use the above framework to write a working version of the shopping mall. b. Your project must have at least one customer, three stores and five items for sale

at each store. c. Implement the user interface any way you like, either textual or graphical. d. Your project must implement the following design patterns:

i. Abstract Factory with Factory Methods Create all stores using factories.

ii. Singleton Allow only one instance of any factory type you create.

iii. 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.

iv. Command Use the Command pattern to encapsulate the actions specified by the user (for example, enter the store, add an item to the shopping cart) and then provide an "undo" capability. That is, allow the user to undo a previous command.

Feel free to use any other patterns you feel appropriate.e. Objectively and critically evaluate your solution including an appraisal of the

suitability of each design pattern for implementing object oriented solutions.

Assignment Deliverables:Level 3 Asia Pacific University of Technology and Innovation 2013

Page 4: design pattern question

CT070-3-3 Design Patterns Individual Assignment Page 4 of 4

You should submit a hardcopy and an electronic copy of the assignment.

The hard copy of the assignment must include the following: A cover page Table of contents Overview of the application Brief description of the system architecture User interface documentation Brief report describing the use of design patterns Refined class diagram as a result of implementing design patterns Critical appraisal report References Appendix (Instructions on how to install and run the program should be provided

in an Appendix)

The electronic copy of the assignment must include the following: All source files (Your assignment code must be well documented and use a

reasonable indentation style. In particular, places where design patterns are implemented should be noted in the code.)

All class files Any makefile, if used Your Assignment Documentation

MARKING CRITERIA

Your project will be graded according to the following criteria: Program Correctness - 20%

o The program performs all of its required functions properly. o The program has no bugs. o The program handles appropriate error conditions properly. o The program operates with reasonable efficiency.

Proper implementation of all required design patterns - 25% Coding Style - 10%

o Good readability and understandability. o Proper use of indentation to highlight function flow control. o Proper use of comments to highlight distinct features/sections.

Assignment Report - 20% (Overview, system architecture, user interface documentation, report describing the use of design patterns and refined class diagram)

Critical Appraisal report - 25%

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.

Level 3 Asia Pacific University of Technology and Innovation 2013