Build Class Diagram
Build Class Diagram
You are required to build the class diagram to manage some staffs and tasks. Each staff is managed by
the manager. The staff includes information: Staff ID, name, gender, basic salary, bonus salary (if the
staff is a manager, he/she will be paid a bonus salary). Each task is performed by one or many staffs.
This system need to record working hours of each staff per a task. Information of task includes: id, title,
begin date, end date, total hours.
1)OOA
Main noun: Task (id, title, begin date, end date, total hours)
2)OOD: UML Working hours
Staff
perform
ID: number
name: text
gender:text 0..* Task
basicSalary: number 1..* ID: number
//methods title: text
Is performed
toString(){…} beginDate:number
1..* endDate: number
totalHours:number
Is managed //methods
extends
1 Manage
Manager
bonusSalary:number
//methods
3)OOP
Exercise 2:
You are required to build the class diagram for a health hospital. This diagram is used to manage some
owners, some pets and services. The owner includes information: ID, name, address. Each owner has
one or many pets. Information of pet includes: id, name, birthday, gender. When a pet uses any services
the system needs to record them to charge money. Each service contains: Id, name, price
Owner Pet
Services
1..*
-ID:String -Id:int 1..*
-Id:int
- name:String -name:String
-name:String
- address:String 1 -birthday:String
-price:int
//methods -gender:String 1..*
//methods
//methods
id=1
name=”chim”
P1=1000
bd=”1/1/2000”
gender=”cai”
owner=null 400
id=2
name=”meo”
P2=2000
bd=”1/1/2014”
gender=”cai”
owner=null 400
id=”O123”
name=”Tien Minh”
owner=400
address=”SG”
id=1
name=”tam”
S1=500
price=100000
id=2
name=”cat mong”
S2=700
price=200000
pet=null 1000
X=800 service=null 500
pet=null1000
y=900 service=null 700
List1=100 List:null200
300
MAX=100 0
n=0 1 2;
400
1
500
2
Id=1
Name:”chim
gender:…
Id=2 99
Name=”cho”
Idremove=2
gender=”…”
Id:3
Name:”vit”
P=400 ……
Exercise 3:
Build a class diagram to manage students and courses of FPTU. Each student includes: id, name, address,
gender. A student can enroll in some courses. Each course contains: code, name, credits. Addition, each
student belongs to the campus. Each campus includes: code, name, address.
1..*
1..*
Campus Student Course
1 1..*
Exercise 4:
Build a class diagram to manager Customers, Items, Orders, invoices. Each Item: id, name, price, status
( 1: đã bán, 0: chưa bán). Customer includes: id, name, address. Order contains: id, orderDate, shipDate,
TotalOfQuantity. Each customer has one or many orders and an order belongs to the customer. Each
Order has only one invoice.
1..*
1..*
Customer order Item
1 1..*
1
1
quantity
Invoice
ma: Number
date: String
Example:
Father Son
Father(){} Son(){}
getter/setter() getter/setter()
bu(){ bu(){
sout(“xoa tay”); Sout(“ha mieng”)
sout(“bop nhe”); Sout(“ngam nhe”)
sout(“phe”); Sout(“nut nut nut”)
} Sout(“no”)
}
Bu2(){…..}
100
70
fields
F2=400 500
Pointer: OFB
fields
F=500
Pointer: OFA
15db9742
x=15db9742 Id=1
name=”abc”
.....
<<abstract>
Car
serial:string
Car(){...}
Car(String){...}
getter/setter(){.....}
brake(){.......}
Abstract void makeTailLight();
CarThaiLand CarVN
price:int discount:int
CarThaiLand(){...} CarVN(){...}
CarThaidLan(String){...} CarVN(String){...}
getter/setter(){.....} getter/setter(){.....}
void makeTailLight(){ void makeTailLight(){
sout(“dinh con voi vao duoi xe”); sout(“dinh hoa vao duoi xe”);
} }
Plant:
fields: name, year
methods: useWater(), grow()
Animal:
Fields: name,gender
Methods:useWater(), grow(), run()
Tester:
<<Abstract>> LivingBeing x=new Plant();
LivingBeing x.useWater();
Exercise 5:
LivingBeing y=new Animal();
Name:text y.useWater();
((Plant)x).grow();
LivingBeing() ((Animal)y).grow();
LivingBeing(text) x.grow();
useWater(){ y.grow()
sout(“used water”);
}
Abstract void grow();
Plant eatBug()
year:int Animal
gender:text
Plant() <<interface>>
Plant(text,int) Food Animal ()
grow(){ Animal(text,text)
implement
extends