Professional Documents
Culture Documents
Making Design Class Diagram: Course Instructor: DR Usman Nasir Course Code: SE331
Making Design Class Diagram: Course Instructor: DR Usman Nasir Course Code: SE331
Lecture 05
Course Instructor: Dr Usman Nasir
Course Code: SE331
Spring 2020
create()
create()
Exercise: 02
Write C++/Java code for this Communication
diagram…
enterItem (itemID, quantity)
:Register
1: getSpecification(itemID)
:ProductCatalog
:ProductSpecification
Visibility
Visibility
Visibility is the ability of an
object to “see” or have addLineItem(itemID, quantity)
ProductSpecification spec =
catalog.getSpecification(itemID);
1: spec :=
getSpecification(itemID) }
:ProductCatalog
Parameter Visibility
Parameter visibility from A to B exists when B is
passed as a parameter to a method of A.
It is a relatively temporary visibility, because it persists
only within the scope of the method.
:Register :Sale
Register Sale
Date
isComplete : Boolean
1 Captures 1 time
addLineItem(…)
… makeLineItem()
makeLineItem()
3: makeLineItem(spec, quantity)
:Register :Sale
Add type information to the attributes and methods.
description amount
price
endSale() getSpecification() itemID
addLineItem()
makeNewSale()
makePayment() Sale
date SalesLineItem
isComplete: Boolean
Store time Quantity: Integer
Register Sale
Date
1 Captures 1 isComplete : Boolean
time
endSale()
addLineItem()
makeLineItem()
makePayment()
class SalesLineItem {
private:
double quantity;
ProductSpecification productSpec;
public :
SalesLineItem( ProductSpecification spec, double qty) {...}
double getSubtotal( ) {…}
… }
ProductSpecification
SalesLineItem description : Text
1 Described-by 1
quantity : Double price : Money
itemID : int
getSubtotal():double
Implementing Methods from Interaction
Diagrams
addLineItem(itemID, quantity)
2 : makeLineItem(spec, quantity)
:Register
:ProductCatalog
:ProductSpecification sli:SalesLineItem
:SalesLineItem
class Register {
private:
ProductCatalog catalog;
Sale tempSale;
public:
void addLineItem(int itemID, double quantity){
ProductSpecification spec;
spec = catalog.getSpecification(itemID);//1
tempSale.makeLineItem(spec, quantity);//2 }
}//end of class
class Sale{
private: SalesLineItem sale_items[100]; int count;
public:
void makeLineItem(ProductSpecification spec, double
quantity){
class diagram?
getSpecification()
Looks-in
1 Sale
Register
Date : Date
Captures isComplete : Boolean
1 time : Time
endSale() 1
becomeComplete()
addLineItem()
makeLineItem()
makeNewSale()
makePayment()
makePayment()
getTotal()
Thank you!!!!
Chapter 18,19, 20 …..
Must read Chapter 19 Section 19.5 and 19.6 for
details