UML Examples
UML Examples
Handout UML_Examples.doc
Notes
All Vehicles have some common attributes (speed and colour) and common behaviour (turnLeft, turnRight) Bicycle and MotorVehicle are both kinds of Vehicle and are therefore shown to inherit from Vehicle. To put this another way, Vehicle is the superclass of both Bicycle and MotorVehicle
1/3
Handout UML_Examples.doc
In our model MotorVehicles have engines and license plates. Attributes have been added accordingly, along with some behaviour that allows us to examine those attributes MotorVehicles is the base class of both MotorBike and Car, therefore these classes not only inherit the speed and colour properties from Vehicle, but also the additional attributes and behaviour from MotorVehicle Both MotorBike and Car have additional attributes and behaviour which arespecific to those kinds of object.
Notes
Each Course object maintains a list of the students on that course and the lecturer who has been assigned to teach that course
2/3
Handout UML_Examples.doc
The Course object has behaviour that allow the adding and removing of students from the course, assigning a teacher, getting a list of the currently assigned students, and the currently assigned teacher. Teachers are modelled as Lecturer objects. As a lecturer may teach more than one course there is an association between Course and Lecturer. The taughtBy relationship shows that a Course only has a single teacher, but that a lecturer may teach several Courses. Each Lecturer object also maintains a list of the Courses that it teaches. There is a similar relationship between Course and Student. A course is attended by zero or more Students, and a Student may attend multiple courses.
This example also demonstrates the use of interfaces. The diagram shows a Person interface that stipulates that objects conforming to this interface will have a getName and getEmailAddress methods. Both Lecturer and Student are shown to be types of Person.
3/3