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

Object Oriented Analysis & Design Lab # 7

The document describes a lab assignment on class diagrams in object-oriented analysis and design. It defines what a class diagram is, its key components and relationships, and provides examples. It then lists 3 tasks - to create class diagrams for (1) a public library system, (2) an archeology research group management system, and (3) a pizza shop ordering system.

Uploaded by

Sonu Sachdev
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)
183 views7 pages

Object Oriented Analysis & Design Lab # 7

The document describes a lab assignment on class diagrams in object-oriented analysis and design. It defines what a class diagram is, its key components and relationships, and provides examples. It then lists 3 tasks - to create class diagrams for (1) a public library system, (2) an archeology research group management system, and (3) a pizza shop ordering system.

Uploaded by

Sonu Sachdev
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/ 7

Object Oriented Analysis & Design

Lab # 7

The objectives of lab 7 are to:


 Understand the Class diagram
 Understand and implement UML notations for Class diagram

Class Diagram:
Class Diagram gives the static view of an application. A class diagram describes the types of objects in the
system and the different types of relationships that exist among them. This modeling method can run with
almost all Object-Oriented Methods.
UML Class Diagram gives an overview of a software system by displaying classes, attributes, operations, and
their relationships. This Diagram includes the class name, attributes, and operation in separate designated
compartments.

Class Diagram helps construct the code for the software application development.

Benefits

 Class Diagram Illustrates data models for even very complex information systems
 It provides an overview of how the application is structured before studying the actual code. This can
easily reduce the maintenance time
 It helps for better understanding of general schematics of an application.
 Allows drawing detailed charts which highlights code required to be programmed
 Helpful for developers and other stakeholders.

Essential elements of A UML class diagram

Essential elements of UML class diagram are:

1. Class Name
2. Attributes
3. Operations

Relationships

There are mainly three kinds of relationships in UML:

1. Dependencies
2. Generalizations
3. Associations
Dependency

A dependency means the relation between two or more classes in which a change in one may force changes
in the other. However, it will always create a weaker relationship. Dependency indicates that one class
depends on another.

In the following example, Student has a dependency on College

Generalization:

A generalization helps to connect a subclass to its superclass. A sub-class is inherited from its superclass.
Generalization relationship can't be used to model interface implementation. Class diagram allows inheriting
from multiple superclasses.

In this example, the class Student is generalized from Person Class.

Association:

This kind of relationship represents static relationships between classes A and B. For example; an employee
works for an organization.

Here are some rules for Association:

 Association is mostly verb or a verb phrase or noun or noun phrase.


 It should be named to indicate the role played by the class attached at the end of the association path.
 Mandatory for reflexive associations

In this example, the relationship between student and college is shown which is studies.
Multiplicity

A multiplicity specifies whether the association is mandatory or not. It has some lower bound and upper
bound.

Let's say that that there are 100 students in one college. The college can have multiple students.

Aggregation

Aggregation is a special type of association that models a whole- part relationship between aggregate and its
parts. It is “part of” relation.

Composition: The composition is a special type of aggregation which denotes strong ownership between
two classes when one class is a part of another class it is “entirely made of” relation.
Aggregation vs. Composition

Aggregation Composition
Aggregation indicates a relationship where the child Composition display relationship where the child will
can exist separately from their parent class. Example: never exist independent of the parent. Example:
Automobile (Parent) and Car (Child). So, If you House (parent) and Room (child). Rooms will never
delete the Automobile, the child Car still exist. separate into a House.
Example of UML Class Diagram:

Creating a class diagram is a straightforward process. It does not involve many technicalities. Here, is an
example:

Sample Scenario: A company consists of departments. Departments are located in one or more offices. One
office acts as headquarter. Each department has a manager who is recruited from the set of employees. Your
task is to model the system for the company.
Exercise
Task 1: Create a class diagram for a web based public library. A public library typically stores a
collection of books, movies, or other library items available to be borrowed by people living in a
community. Each library member typically has a library account and a library card with the account’s
ID number, which she can use to identify herself to the library. A member’s library account records
which items the member has borrowed and the due date for each borrowed item. Each type of item
has a default rental period, which determines the item’s due date when the item is borrowed. If a
member returns an item after the item’s due date, the member owes a late fee specific for that item,
an amount of money recorded in the member’s library account.

Task 2: Create a class diagram based on the following description. You have been asked to build
a management system for a group of archeologists. The group is comprised of multiple teams of
researchers. Each team has a letter ID (e.g., team A, team B). Each researcher belongs to one of the
teams, and has an ID number, a first name, and a last name. There are two types of researchers: field
and lab staff. Each field staff member has a favorite region (string). Each lab researcher supports up
to 2 field researchers. Some researchers may not be supported by a lab researcher. The company also
manages an inventory of equipment. Researchers of any type may check out up to 3 pieces of
equipment. Each piece of equipment has a serial number and replacement cost.

Task 3: Imagine that you are tasked with developing a system for a pizza shop. Given the following
description, create a class diagram (in the form of a UML class diagram). Include all conceptual classes,
attributes, associations, and generalization relationships mentioned in the descriptions. Label all
associations and include all multiplicities.
A customer places orders. A customer has a name and phone number. There are two types of orders:
pick-up and delivery. A pick-up order has a pick-up time. A delivery order has an address and deliver-
by time. All orders consist of a set of items. There are two types of items: pizzas and drinks. All items
have a price. A pizza has a size and a crust type. A pizza also has a number of toppings. A topping has
a topping type and a price. Some pizzas are special pizzas that have a name (e.g., “Hawaiian” or “Meat
Lovers”). A drink has a brand and a flavor.

You might also like