Practical Session 2 Class Design
UML Basics UML - Unified Modeling Language
Class Diagram Name Car Fields Methods - engineSize : int - maxSpeed : int # getMaxSpeed() : int + drive() Permissions notation: + public, - private, # protected.
C has a collection of objects of type D Relations A B A has an object of type B n C D C has a collection of objects of type D
Relations example Car Wheel - engineSize : int - maxSpeed : int + drive() # getMaxSpeed() : int Wheel - airPressure: double + roll() 4
Inheritance Base Car Derived Ferrari
Interface Implementation Vehicle Implementation Car
Abstract Class Name* Car * Fields Non Abstract Methods - engineSize : int - maxSpeed : int # getMaxSpeed() : int + drive() *
Shape Hierarchy example
ShapeBase * - canv : Canvas - offset : Point + draw() * + delete() * + move(p: Point) Shape draw() delete() move(p: Point) n Polygon Point Circle Triangle Rectangle Square