Presentation is loading. Please wait.

Presentation is loading. Please wait.

Problem specification:

Similar presentations


Presentation on theme: "Problem specification:"— Presentation transcript:

1 Problem specification:
In class exercise (I) Problem specification: An e-commerce company based in Maryland, U.S. called Dogwood, needs an online sale system. You are asked to write the part of the system to deal with sale order.

2 Stage One Step I. Create the class library for sale order
Implement the sale order class according to the following specification. Please note that this class is not responsible for getting input from users. You must assume that the information needed is passed in through its constructor. Class Attributes Operations SaleOrder customName, Calculate price before tax Calculate itemSold, Calculate tax amount itemQuantity, Calculate total price unitPrice Display a receipt with custom name, item sold,quantity, unit price, tax amount and total price. Step II. Write an application using the sale order library Write an application to test the above class you create. Basic things you need to do are to create an object of SaleOrder and to see if the receipt is displayed properly.

3 First SaleOrder Design
-itemQuantity: integer -unitPrice: double -itemSold: string -customerName: string +calTax(): double double calcTax(){ return itemQuantity*unitPrice*0.05; }

4 Result of Stage One: Your library works so well for Dogwood
Another two e-commerce companies based in Maryland, Elm and Holly, bought your library and used it in their on-line sale application as well.

5 Stage Two: Requirement changes:
Dogwood’s business is booming and they decide to extend their business to Delaware. You are asked to rewrite the sale order library to deal with the taxation rule with both Maryland and Delaware.

6 Step I. Changing requirement leading to changing sale order library
Step II. Write an application using the new sale order library Write an application to test the above class you create. Basic things you need to do are to create an object of SaleOrder and to see if the receipt is displayed properly for both Maryland and Delaware customers.

7 Result of Stage Two: Your library works so well for Dogwood’s business in Delaware and Maryland. You also sold your new library to an Delaware and Maryland e-commerce firm called Chestnut. Due to your change to sale order library, Elm and Holly are affected.

8 Stage Three: Requirement changes:
Dogwood’s business is booming again and they decide extend their business to the rest of U.S. You are asked to rewrite the sale order library to deal with the taxation rule with all the states in U.S..

9 Step 0. Before we do anything, we need to sit back and think first.

10 Identify the changing part
Requirement changes Identify the changing part What got us into this mess? How can we make our design flexible? Separate changing part design Implement changes without affecting the existing What is changing in sale order? tax and how tax is calculated

11 <<interface>>
New SaleOrder Design SaleOrder -saleTax: SaleTax +calTax(): double <<interface>> SaleTax +calcTax(…): double double calcTax(){ return saleTax.calcTax(…); } USTax +calTax(…): double CanadaTax +calcTax(…): double GermanyTax +calcTax(…): double

12 Step 1. Implement the new sale order class according to the new design

13 Step II. Write an application using the new sale order library
Write an application to test the above class you create. Your application should be something like: SaleOrder saleOrder1 = new saleOrder(“Joe”,“appletSeed”,10,1.0, new USTax()); SaleOrder saleOrder2 = new saleOrder(“Mary”,“roseTree”,2,25.0, new CanadaTax());

14 Change requirement on tax calculation on old design
App2 App1 SaleOrder -itemQuantity: integer -unitPrice: double -itemSold: string -customerName: string +calTax(): double App3 App4

15 Change requirement on tax calculation on new design
App1 SaleOrder -saleTax: SaleTax +calTax(): double <<interface>> SaleTax +calcTax(…): double App2 App4 App3 USTax +calTax(…): double CanadaTax +calcTax(…): double GermanyTax +calcTax(…): double NewZealandTax +calTax(…): double

16 Problem One Specification:
In class exercise (II) Problem One Specification: You and your friend started a company to deliver software solution to customer problem. 2. Your first business is from Salisbury University Register’s office. They are using a class library to keep course information. Their current class library allow to sort the students list using a selection sort. 3. Now they ask you to improve the design to allow different sorting strategy being used.

17 Current Course Class Design
-title: string -instructor: string -students: string[] …… +sortStudents(): void Application Course calcII = new Course(…); calcII.sortStudents(); void sortStudents(){ // selection sort of students array … … }

18 New Course Class Design
-title: string -instructor: string -students: string[] ?????? +sortStudents(): void Application Course calcII = new Course(…, new BubbleSort()); or calcII.setSortStrategy(new BubbleSort()); calcII.sortStudents(); void sortStudents(){ // sort of students array ?????? }

19 Problem Two Specification:
1. Your second business is from Perdue Stadium Ticket Office. They asked you to write a class library to calculate ticket sale price. 2. Here are the rule for ticket sale at Perdue Stadium: Ticket sale price consist of two parts: ticket price and sale tax. Ticket price also varies between children, and adult.

20 Your view Short sighted with quick and dirt approach
Long term with solid and clear approach

21 <<interface>>
SaleOrder Design SaleOrder -saleTax: SaleTax +calTax(): double <<interface>> SaleTax +calcTax(…): double double calcTax(){ return saleTax.calcTax(…); } USTax +calTax(…): double CanadaTax +calcTax(…): double GermanyTax +calcTax(…): double

22 -sortStrategy: SortStrategy +sortStudents(): void
Course -title: string -instructor: string -students: string[] -sortStrategy: SortStrategy +sortStudents(): void +setSortStrategy(SortStrategy): void <<interface>> SortStrategy +sort(string[]):void void sortStudents(){ // sort of students array sortStrategy.sort(students); } BubbleSort +sort(string[]):void SelectionSort +sort(string[]):void QuickSort +sort(string[]):void

23 -priceStrategy: PriceStrategy -taxStrategy: TaxStrategy …
Senior +getAmt(…):doubld Children +getAmt(…):double Adult +getAmt(…):double TicketSale -priceStrategy: PriceStrategy -taxStrategy: TaxStrategy +getAmt(): double <<interface>> PriceStrategy +getAmt(…):double <<interface>> TaxStrategy +getAmt(…):double double getAmount(){ return priceStrategy.getAmt(…) + taxStrategy.getAmt(…); } US +getAmt(…):doubld Canada +getAmt(…):double Germany +getAmt(…):double


Download ppt "Problem specification:"

Similar presentations


Ads by Google