250 likes | 410 Views
Introduction to UML. What is UML. UML stands for U nified M odelling L anguage. A way to talk about Object Oriented Design. UML is a visual language. first. second. third. class :. Colour. instance :. attribute :. hue. value :. "blue". name :. second. first.
E N D
What is UML UML stands for Unified Modelling Language A way to talk about Object Oriented Design UML is a visual language
first second third class : Colour instance : attribute : hue value : "blue" name : second
first second third actual instance second : Colour third : Colour Colour first : Colour Class (UML) hue : String hue : "red" hue : "blue" hue : "green" instance(UML) "green" "red" "blue"
Shape form : String shape1 : Shape shape2 : Shape shape3 : Shape form = "triangle" form = "rectangle" form = "pentagon" shape1 shape2 shape3 setShape( String)
Shape form : String setShape( String) shape3 : Shape form = "pentagon" shape1 shape2 shape3 form = "hexagon" shape3.setShape("hexagon")
Attributes ColouredShape hue : String form : String setHue( String) setShape( String) shape1 : ColouredShape hue = "blue" form = "triangle" methods State of an instance is the values held in its attributes shape1 shape2 shape3
shape1 : ColouredShape shape3 : ColouredShape shape1 : ColouredShape shape3 : ColouredShape hue = "blue" form = "triangle" hue = "green" form = "hexagon" hue = "red" form = "triangle" hue = "green" form = "octagon" shape1 shape2 shape3 shape1.setHue("red") shape3.setShape("octagon")
ward bedNumber occupied patient getWard( ) :String getBedNumber( ) : int isOccupied( ) : boolean getPatient ( ) : Patient empty( ) fill( Patient ) Exercise 1 attributes types String integer boolean Patient A hospital bed methods List all the attributes you can think of for a hospital bed For each attribute write down the type of the value List all the methods you can think of for a hospital bed
Exercise 1 Draw a class diagram for a HospitalBed
HospitalBed ward : String bedNumber : integer occupied : boolean patient : Patient getWard() :String getBedNumber():integer isOccupied() :boolean getPatient() :Patient empty() fill( Patient)
«instance of» CurrentBed:HospitalBed ward : "Iris" bedNumber : 14 occupied : TRUE patient : fred fred HospitalBed ward : String bedNumber : integer occupied : boolean patient : Patient getWard():String getBedNumber():integer isOccupied():boolean getPatient():Patient empty() fill( Patient)
Exercise 1 attributes types patientID name address bedNumber ward dateOfAdmission DoB consultant notes String String String integer String Date Date Doctor Notes bed Bed Patient Write down attributes for a patient ...and their types
typical Patient instance freddy : Patient name = "Fred Smith" address = "14 Penny Lane" DOB = (07/12/1962) PatientID = "CM897DT" Bed = ("Rose",17) dateOfAdmission = (15/9/2003) consultant=(32331, "Dr A Dass", "Oncology") notes = (File: 2877738)
BankAccount accountNumber: String accountName : String balance : double deposit( amount : double) withdraw(amount : double) getAccountNumber():String getAccountName():String getBalance():double Exercise 2 Draw a class diagram for a Bank account
first : BankAccount accountNumber: "123212" accountName : "Fred" balance : 1029.34 second : BankAccount accountNumber: "786348" accountName : "Harry" balance : 1.77 fourth : BankAccount accountNumber: "858838" accountName : "Hans" balance : -7.34 third : BankAccount accountNumber: "498101" accountName : "Asif" balance : 1102.95 fifth : BankAccount accountNumber: "573562" accountName : "Nadine" balance : 20351.12 Instances of the class BankAccount BankAccount accountNumber: String accountName : String balance : double deposit( amount: double) withdraw( amount: double) getAccountNumber():String getAccountName():String getBalance():double
Rectangle height : double width : double area(): double perimeter(): double Exercise 3 Draw a class diagram for a Rectangle. The methods include finding the area and perimeter of the rectangle getHeight(): double getWidth(): double setHeight( aHeight: double) setWidth( aWidth: double)
Item itemNo : String description : String itemCost : double numberInStock : integer reorderLevel : integer row : integer bay : integer level : integer Exercise 4 Write aclass diagram for an item stored in a warehouse ( ignore methods) Problem: If no item in a location in the warehouse, there is nothing recording the state of that location.
Item Location itemNo : String description : String itemCost : double numberInStock : integer reorderLevel : integer row : integer bay : integer level : integer Exercise 4 0..1 Item Location 1 If the system was also used to create a catalogue, an item not held in stock cannot appear in the catalogue! ... much later ...
1 * 1 0..1 1 * 1 * 1 * CatalogueItem Catalogue itemNo : String description : String itemCost : double Item numberInStock : integer reorderLevel : integer isOrdered : boolean Box numberPerBox: integer boxIdNo : String Location row : integer bay : integer level : integer WareHouse
Exercise 5 A system keeps track of the arrivals and departures of aircraft at any airport for an airline. Identify classes and attributes that might be used by the system Flight Time Date FromLocation Destination FlightNumber more?
Exercise 5 Flight A system keeps track of the arrivals and departures of aircraft at any airport for an airline. Identify classes and attributes that might be used by the system from to number Date Time year month day hours minutes seconds
Exercise 5 Flight number time : Time date : Date Arrival Departure to: String from: String