Practical Session 2 Class Design
This practical session explores the fundamentals of UML Class Diagrams, focusing on the Class design of a Car and Shape hierarchies. We delve into specific components such as attributes (like engineSize and maxSpeed) and methods (including drive and getMaxSpeed). Additionally, the relationships between classes are illustrated with examples showing composition and inheritance. The session also covers interface implementation and the differences between abstract and non-abstract methods, providing a comprehensive understanding of UML and its application in object-oriented design.
Practical Session 2 Class Design
E N D
Presentation Transcript
Class Diagram Name Fields Methods Car - engineSize : int - maxSpeed : int # getMaxSpeed() : int + drive() Permissions notation: +public, - private, # protected.
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 - engineSize : int - maxSpeed : int + drive() # getMaxSpeed() : int Wheel - airPressure: double + roll() 4
Inheritance Base Car Derived Ferrari
Interface Implementation Interface Vehicle Implementation Car
Abstract Class Name* Fields Non Abstract Methods Abstract methods * Car * - engineSize : int - maxSpeed : int # getMaxSpeed() : int + drive() *
ShapeBase * - canv : Canvas - offset : Point + draw() * + delete() * + move(p: Point) Shape draw() delete() move(p: Point) n Polygon Point Circle Triangle Rectangle Square