0% found this document useful (0 votes)
45 views5 pages

Chapter 2 - Exercises PDF

The document contains instructions for three exercises to create UML class diagrams based on requirements. Exercise 1 requires a class diagram for an invoice with attributes like number, date, amount for the invoice and line items with attributes like quantity and price. The invoice can add and remove line items. Exercise 2 requires a class diagram for a file system with folders that can contain files and other folders. Folders have attributes like name and permissions and can delete files or get files by extension. Exercise 3 requires a class diagram representing a company with classes like departments with employees, projects employees can work on, and specializations like supervisors and internal/external projects.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views5 pages

Chapter 2 - Exercises PDF

The document contains instructions for three exercises to create UML class diagrams based on requirements. Exercise 1 requires a class diagram for an invoice with attributes like number, date, amount for the invoice and line items with attributes like quantity and price. The invoice can add and remove line items. Exercise 2 requires a class diagram for a file system with folders that can contain files and other folders. Folders have attributes like name and permissions and can delete files or get files by extension. Exercise 3 requires a class diagram representing a company with classes like departments with employees, projects employees can work on, and specializations like supervisors and internal/external projects.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

CSC 323 – Object-Oriented Design Dr. Pierre A.

Akiki
Chapter 2 – UML Class Diagrams

Exercise 2.1 – Class Diagram for Invoice

You are required to create a class diagram that represents an invoice, based on
the requirements stated below. The diagram should contain classes,
relationships, attributes, and methods. You should specify the data types and
visibility as appropriate. Consider all the attributes to be publicly visible.

Each invoice has a: number, date, total amount, customer reference, and
currency reference. An invoice is composed of many lines (whenever we remove
an invoice all lines are also removed). For each line, you should retain the
following information: line number, item reference, quantity, unit price, vat
percentage, extended price. Invoices and lines can internally calculate their
total amount and extended price respectively (no return value is expected). An
invoice should expose functionality for adding and removing lines, by supplying
an item reference or a line number respectively as a parameter (no return value
is expected).

Exercise 2.2 – Class Diagram for File System

You are required to create a class diagram that represents a file system based
on the requirements stated below. The diagram should contain classes,
relationships, attributes, and methods. You should specify the data types and
visibility as appropriate. Consider all the attributes to be publicly visible.

The file system has folders, which are composed of files. You are required to
retain each folder’s name, and whether or not it is read-only. You are required
to retain each file’s name and extension (e.g., “.jpg”, “.exe”, etc.). A folder should
expose a delete operation (no return value expected). Additionally, a folder
should expose an operation that gets the files inside it, based on a given
extension (e.g. get all files that have an “exe” extension). Also, note that folders
can be nested within one another.
CSC 323 – Object-Oriented Design Dr. Pierre A. Akiki
Chapter 2 – UML Class Diagrams

Exercise 2.3 – Class Diagram for Company

You are required to create a class diagram for representing classes that can hold
information on a company.

Assume that there are multiple departments. A department has a name, and
an employee count (number-of-employees attribute). Each department can have
many offices. An office has an address and multiple phone numbers.

A department employs multiple employees but is only managed by one of them.


Each employee can only work for one department. An employee may be a
supervisor, and thereby supervises other employees. Each employee has a first
name, last name, date of birth, and age.

Each employee can work on 1 to 3 projects, and a project can have 5 to 10


employees working on it. A project has a name and a deadline.

A project can be of two different types: internal or external. Internal projects


are commissioned by one or more departments and may be urgent. External
projects have a customer name.
CSC 323 – Object-Oriented Design Dr. Pierre A. Akiki
Chapter 2 – UML Class Diagrams

Exercise 2.1 – Solution


CSC 323 – Object-Oriented Design Dr. Pierre A. Akiki
Chapter 2 – UML Class Diagrams

Exercise 2.2 – Solution


CSC 323 – Object-Oriented Design Dr. Pierre A. Akiki
Chapter 2 – UML Class Diagrams

Exercise 2.3 – Solution

You might also like