0% found this document useful (0 votes)
86 views

Build Class Diagram

The document describes building class diagrams for various exercises involving modeling relationships between different entities. The first exercise involves modeling staff, managers, tasks and working hours. The second involves modeling owners, pets, and veterinary services. The third involves modeling students, courses, and campuses. The fourth involves modeling customers, items, orders, and invoices.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
86 views

Build Class Diagram

The document describes building class diagrams for various exercises involving modeling relationships between different entities. The first exercise involves modeling staff, managers, tasks and working hours. The second involves modeling owners, pets, and veterinary services. The third involves modeling students, courses, and campuses. The fourth involves modeling customers, items, orders, and invoices.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Exercise 1:

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: Staff ( ID,name, gender, basic salary)

Main noun: Manager(ID,name, gender, basic salary, bonus salary)

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

z=600 pet=null 2000


service=null 500

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(){…..}

Father f=new Father();


OFA OFB
f.bu();
Class Father Class Son
fields fields
Son s=new Son();
s.bu();
Father() 10 Father() 10
Father f2=new Son(); f2.bu(); getter () 20 getter () 20
... ..
((Son)F2).bu2() bu() 70 Son() 100
bu() 500
10

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)

sout(“by light”); } void eatBug();// abstract grow(){


sout(“by food”); }

implement
extends

Orchid Venus(bat ruoi) Thằn lằn Cat


Price:int
eatBug(){

You might also like