Chapter 2 - Exercises PDF
Chapter 2 - Exercises PDF
Akiki
Chapter 2 – UML Class Diagrams
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).
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
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.