You are on page 1of 10

Hong Kong Institute of Vocational Education IT Discipline

Object-oriented Technology Workshop 2 Suggested Solution Part 1 i)

ii) iii)

Composition : if MailMessage is to be removed, Header should also be removed. Aggregation : if MailMessage is to be removed, there is no need to remove Attachment as Attachment can exist by itself alone.

Part 2

Part 3 Candidate classes: Bank (concept) Branch (concept) Branch number (simple value - irrelevant) Account (concept) Account number (simple value - irrelevant) Savings Account (concept) Interest (simple value irrelevant) Cheque Account(concept) Cheque (tangible) Cheque number (simple value - irrelevant) Revised list of candidate classes: Bank (concept) Branch (concept) Account (concept) SavingsAccount (concept) ChequeAccount(concept) Cheque (tangible)

1. 2. 3. 4.

The distinction between Bank and Branch classes is crucial. The relationship between Bank/Branch is composition. Branch can only be created after Bank is created, but Branch will be explicitly removed before the destruction of Bank. Since SavingsAccount and ChequeAccount have some properties in common. A super class Account can be used to generalize the commonalities. A lot of other important candidate objects have not been mentioned in the problem statement and is outside the scope of this model.

Part 4 Identify objects and classes using textual analysis We can perform a textual analysis to extract the nouns or noun phrases and then decide whether the nouns or noun phrases are candidate objects. Problem Statement of an Online Book Store The Pearl River Book Company is developing an online book store system through which its customers can buy books and sell their used books. Public users are those who are not registered customers of the system. Public users or registered customers can search books by entering keywords, which may appear in the title, author, or the book description. The system displays a list of books that matches the keywords. Each entry of the book list consists of the book title, author(s), the price for a new copy and the price range for used copies. The user can select a book from list to display more detail information about it (availability, price for new copy, prices for used copies, table of contents, author, ISBN). The user can add a copy of the book (either new or old) to the shopping cart. The user can then continue to search for another book. When the user finishes searching, the user can check out the books in the shopping cart. The system asks the user to login his/her account by entering the users email address and the account password. If the user has not registered yet, the user can register for a new customer account at that point. The user enters the email address, the home address and the password. The system verifies that the email address has not been used by an existing customer before confirming the creation of the new customer account through an email message. The system then asks the user to select the shipping option (express, priority, or ordinary). Different shipping options have different prices. The user can then select the payment method (credit card or the user account of the book store). If the user selects the credit card payment method, the user enters the card number, type, and expiry date. The system then sends the credit card information and the amount charged to the external payment gateway. The amount is calculated by adding the prices of the selected books and the selected shipping option. If the credit card transaction is approved, the external payment gateway will send back an approval code. Otherwise, the system will ask the user to re-select the payment method and re-enter the payment information. If the user selects payment by his/her account with a sufficient balance, the system charges the amount to the customer account. Otherwise, the system asks the user to re-select the payment method. Upon completion of payment, the system arranges delivery of the ordered books. An external shipping agent is responsible for the delivery of the ordered books. If an order involves new books, the system sends a shipping request to notify the shipping agent to collect the books from the book store. New books in the same order are shipped together. If a used book has been ordered, the system sends a delivery request to notify the seller of the book and a shipping request to the shipping agent of the book store. The shipping agent collects the book from the seller and delivers the book to the buyer. Used books of the same order from the same seller are shipped together. After the book(s) has/have been delivered to the buyer, the shipping

agent sends a shipping completion message to the system. Upon receipt of this message, the system updates the sellers customer account by adding the price of the used book minus the commission charge for the service. A public user or a registered customer who wants to sell a used book can go through the above process in searching a book and displaying its information. The user can then post a used copy for sale. The system will ask the user to enter the price and the general condition of the used book. Then the system further asks the user to enter the email address and password of his/her customer account for login. If the user does not have a customer account, the user can create a new customer account as described in previous paragraph. Candidate classes: public user email address (simple value) home address (simple value) password (simple value) system account (concept) new customer (role played) acknowledgement user (covered by public user or customer) email customer (role played) book (tangible thing) book description (attribute) title (attribute) author (attribute) keywords (simple value) detail information of book (attributes) availability (attribute) table of contents (attribute) ISBN (attribute) keywords of the book (simple value) list of books used copy (tangible thing) shipping cart books in the shopping cart (tangible thing) payment gateway (tangible thing) shipping option (simple value) total amount (simple value) payment method (simple value) required information (simple value) credit card payment (concept) card number (attribute) transaction (event)

shipping request (event) shipping agent (role played) price (simple value) condition (simple value) sale order (event) shipping completion message commission charge (simple value) sellers account (concept) buy orders status (simple value) Revised list of candidate classes: customer (role played) book (tangible thing) new copy (tangible thing) used copy (tangible thing) account payment (concept) credit card payment (concept) buy order (event) shipping agent (role played) shipping option (simple value) payment gateway (tangible thing) Develop a data dictionary Class customer Definition A customer holds details of personal particular, such as account password, email address, home address. A customer can search book by keywords, register for an account. After account creation, the customer can login, adds copy of the book into shopping cart. A book may have one or more copy(/copies). It holds detail of the book such as book title, author, ISBN. A customer can buy a new copy of the book. A customer can post his/her used copy of the book and sell it. Each used copy of the book has its own price, availability. It holds the account balance of a customer. It holds details of the credit card, such as card number and expiry date. A customer can add a buy order to buy new/used copy of book. It specifies payment option, shipping option. A buy order can have one or more copy(/copies) of book. It handles the shipping request and sends a shipping completion message when the book(s) is/are delivered. It holds the type and the price of a specified shipping option.

book new copy used copy account payment credit card payment buy order shipping agent shipping option

payment gateway It processes the credit card payment of a credit card account. Identify associations between classes Verb phrase The customer adds a copy of the book into the shopping cart. The system displays the books in the shopping cart. The customer checks out the book. The system asks the customer to login. i.e. a order is placed by a customer The customer posts a used copy of the book for sale. i.e. a used copy is posted by a customer The system confirms the transaction and sends the shipping request to the shipping agent. i.e. a buy order is handled by a shipping agent. a buy order is completed by a shipping agent. The system charges the amount to the customers credit card account or account. i.e. a buy order is paid by credit card payment or account payment The customer adds a copy of the book into the shopping cart. The system displays the books in the shopping cart. i.e. a book has new copy The customer posts a used copy of the book for sale. i.e. a book has used copy If the customer selects credit card payment, the amount is charged to the customers credit card through the payment gateway. i.e. a credit card payment is approved by payment gateway The buy order has used copy and/or new copy of books. The customer selects the shipping option. The system displays the total amount. a buy order has shipping option Association placed by

posted by handled by, completed by paid by has has approved by has, has has

Initial domain class model

Class diagram with attributes

Association class Delivery Request is added since the system will send the delivery request to the shipping agent. The delivery request should hold collecting and delivery addresses. Association class Completion Message is added since the shipping agent will send the completion message back to the system with an actual delivery date. list_price in New Copy holds the list price of a new copy. price in Used Copy holds the price of an used copy. Shipping Option holds the charges of different options.

Refined class diagram with inheritance

A super class Copy is added. The Used Copy and New Copy is inherited from Copy since the association between Used Copy and Buy Order is the same as New Copy and Buy Order. The Used Copy and New Copy is specialized from Copy. A OrderLine association class is added since the order line of buy order can hold the price of the copy (both new copy and used copy) at that moment. The price in class Copy may change from time to time. A super class Payment is added since both the Credit Card Payment and Account Payment is going to process payment of the buy order. The Account Payment is removed since there is no significant attribute in the class Account Payment. The operations can be performed by its super-class Payment.

Class diagram after test access path

A class Credit Card and an association between Customer and Credit Card are added in order to allow the customer to use a credit card, which has been used before. Moreover, association between Credit Card Payment and Credit Card is added.

10

You might also like