0% found this document useful (0 votes)
11 views7 pages

Object Oriented Programming Lab

Uploaded by

abeeruxx99
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)
11 views7 pages

Object Oriented Programming Lab

Uploaded by

abeeruxx99
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/ 7

OBJECT ORIENTED PROGRAMMING – LAB

Student Name:
Abeer Alawi – Nora Al Hosani
Course Code:
SWE-321-002
Instructor’s Name:

IN CLASS EXERCISES
Homework:
Task 1: For UML class diagram given below, identify the classes and their
relationships and multiplicity. Based on your understanding of the class
diagram (below), write a paragraph explaining all classes and their
relationships.

Answer:
Classes and Attributes:
1. University: Represents a university entity that has relationships with other
entities.
2. Department: A department is a part of the university. Each university
contains one or more departments.
3. Room: Represents rooms within the university, which can be classified
further into offices or classrooms.
4. Office: A type of room within the university where employees work.
5. ClassRoom: Another type of room within the university used for teaching
purposes.
6. Person: Represents individuals associated with the university. This class
generalizes the two sub-classes of Professor and Employee.
7. Professor: A type of person that works in the university. Professors can be
further classified as Full Professors, Associates, or Assistants.
8. Employee: Another type of person who works in the university, which might
not necessarily be a professor.
9. FullProfessor, Associate, Assistant: These are specific roles that a
Professor can have.
Relationships:
 University to Department: There is a one-to-many (1..*) relationship,
meaning a university has one or more departments.
 University to Room: There is a one-to-many (1..*) relationship, indicating
that a university contains multiple rooms.
 Department to Person: There is a one-to-many (1..*) relationship, meaning
a department enrolls multiple people.
 Room to Office and ClassRoom: Both Office and ClassRoom are
specializations (subtypes) of Room, implying that rooms can be of these
types.
 Person to Professor and Employee: Person is a generalization (parent
class) of Professor and Employee, indicating that all professors and
employees are persons.
 Professor to FullProfessor, Associate, and Assistant: These three are
specializations of the Professor class, denoting specific types of professors.
 Person to Office: A person works in an office, showing a one-to-one (1..1)
relationship between a person and an office.

Multiplicity:
 University to Department: 1..* (one university can have multiple
departments).
 University to Room: 1..* (one university can have multiple rooms).
 Department to Person: 1..* (one department can enroll multiple persons).
 Person to Office: 1 (each person works in one office).

TASK 2: Design and draw UML class diagram with attributes, behavior, and
class relationships for the following scenario: Model a system for an airline
management system that manages flights and pilots- a. An airline operates
flights. b. Each airline has an ID. c. Each flight has an ID, a departure airport,
and an arrival airport. d. An airport as a unique identifier. e. Each flight has a
pilot and a co-pilot, and it uses an aircraft of a certain type. f. A flight also
has a departure time and an arrival time. g. An airline owns a set of aircrafts
of different types. h. An aircraft can be in a working state, or it can be under
repair. i. In a moment an aircraft can, be landed or airborne. j. A company
has a set of pilots: each pilot has an experience level: 1 is minimum, 3 is
maximum. k. A type of aircraft may need several pilots, with a different role
(e.g.: captain, co-pilot, navigator).

ANSWER:

Following is the explanation of the above diagram:


The UML class diagram represents an Airline Management System. The system
consists of the following entities:
 Airline: Represents an airline company.
 Airport: Represents an airport.
 Flight: Represents a flight operated by an airline, with a departure and arrival
airport, and departure and arrival times.
 Aircraft: Represents an aircraft used by an airline.
 Pilot: Represents a pilot who operates an aircraft.
 AircraftType: Represents the type of an aircraft.
The relationships between the entities are as follows:
 One-to-many:
o An airline can have many flights.

o An airport can have many flights.


o A flight can have many pilots.

o An aircraft type can have many aircraft.

 Many-to-many:
o An aircraft can be used by many flights.
EXPLAINATIION:
The class diagram models the structure of a university system. The University
class represents the overall institution, which contains multiple Departments. Each
department is associated with various Rooms, which can be either Offices or
ClassRooms. The Person class is a generalization for both Professors and
Employees. Professors can have specific roles such as FullProfessor, Associate,
or Assistant. Each person works in a specific Office.
Relationships:
 Inheritance:
o Person is a superclass of Professor and Employee.

o The professor is a superclass of Full Professor, Associate, and


Assistant.
 Association:
o University has a one-to-many relationship with Department.

o University has a one-to-many relationship with Room.

o Department has a one-to-many relationship with Person.

o A person has a one-to-one relationship with Office.

You might also like