Presentation is loading. Please wait.

Presentation is loading. Please wait.

IEG 3080 Tutorial 6 Jack Chan. Prepared by Jack Chan, Spring 2007 Outline UML Basic Class Diagram Sequence Diagram Examples Assignment 2 General Concept.

Similar presentations


Presentation on theme: "IEG 3080 Tutorial 6 Jack Chan. Prepared by Jack Chan, Spring 2007 Outline UML Basic Class Diagram Sequence Diagram Examples Assignment 2 General Concept."— Presentation transcript:

1 IEG 3080 Tutorial 6 Jack Chan

2 Prepared by Jack Chan, Spring 2007 Outline UML Basic Class Diagram Sequence Diagram Examples Assignment 2 General Concept / Classes Responsibilities Sample codes

3 Prepared by Jack Chan, Spring 2007 Unified Modeling Language (UML) Object Management Group (www.uml.org)www.uml.org Standard notation of object-oriented modeling Specification, Visualization, Documentation Usage For Communication between program designers Highlight the essential components As a blueprint for programming Code mapping

4 Prepared by Jack Chan, Spring 2007 UML Structural Diagram E.g. Class Diagram Define static structural model of the classes Show the relationship among different classes Behavior Diagram E.g. Sequence Diagram Interaction diagram Show the exchange of message in time sequence

5 Prepared by Jack Chan, Spring 2007 Class Diagram Structural model of a class Name (name of the class) Attribute (visibility, +, -, #...) (Lecture Notes, P.355) Operation (visibility name(param-list) : return-type {property-string} (Lecture Notes, P.356) Relationship between two classes Association Generalization/Realization Aggregation/Composition

6 Prepared by Jack Chan, Spring 2007 Class Diagram – An example - Form1 contains GameEngine - Game1 and Game2 are inherited from GameEngine - Game contains Enemy, Wall and Child Anything can be improved for this design? 1

7 Prepared by Jack Chan, Spring 2007 Sequence Diagram Show flows of messages, events and actions Time is represented in vertical direction Building blocks Objects Iteration marker *[for all objects] [condition] Self-delegation … Referred to Lecture Notes P.381 Reference: UML Sequence Diagram Tutorial, http://www.sequencediagrameditor.com/uml/sequence-diagram.htm http://www.sequencediagrameditor.com/uml/sequence-diagram.htm

8 Prepared by Jack Chan, Spring 2007 Sequence Diagram – An example -Could you recognize all the building blocks? E.g. objects, conditions, time sequence…. - Could you understand why messages/actions flow through these objects in this way? Lecture Notes P. 380

9 Prepared by Jack Chan, Spring 2007 Another Example IBM, UML’s Sequence Diagram, http://www-128.ibm.com/developerworks/rational/library/3101.htmlhttp://www-128.ibm.com/developerworks/rational/library/3101.html

10 Prepared by Jack Chan, Spring 2007 Assignment 2 – Small Bank Requirements Two customers (two objects in an array) Two accounts (Saving account and Current account) for each of them Deposit certain amount of money into their accounts Print customers’ account summary Add a USD account to each of them Print customers’ account summary again

11 Prepared by Jack Chan, Spring 2007 Classes in Assignment 2 Small_Bank SavingAccountCurrentAccountUSAccount Account Customers What attributes and operations are included in each of the classes?

12 Prepared by Jack Chan, Spring 2007 Responsibilities Who knows the customers? Small Bank Who keeps the accounts? Customer Who knows the account balance? Account itself Who handles Deposit/Withdraw operations? Account itself

13 Prepared by Jack Chan, Spring 2007 Responsibilities Who creates customers? Small Bank Who creates accounts? Customers Who asks to print the account summary of each customers? Small Bank  Customers  Account Why?

14 Prepared by Jack Chan, Spring 2007 Some code samples class Account { protected …; public virtual void Deposit(…) { ……; } public virtual void Withdraw(…) { ……; } public virtual void Print_Balance() { } … to be filled by yourself

15 Prepared by Jack Chan, Spring 2007 Some code samples class Saving : Account { public Saving(…) { …; } public override void Print_Balance() { Console.WriteLine(" The Saving Account: ${0}", this.balance); }

16 Prepared by Jack Chan, Spring 2007 Some code samples private ArrayList acc_list; public Customer(String name, int acc_no) { this.name = name; this.acc_no = acc_no; Account saving_acc = (Account) new Saving(0); Account current_acc = (Account) new Current(0); acc_list = new ArrayList(); acc_list.Add(saving_acc); acc_list.Add(current_acc); }

17 Prepared by Jack Chan, Spring 2007 Sample Output


Download ppt "IEG 3080 Tutorial 6 Jack Chan. Prepared by Jack Chan, Spring 2007 Outline UML Basic Class Diagram Sequence Diagram Examples Assignment 2 General Concept."

Similar presentations


Ads by Google