Vous êtes sur la page 1sur 23

oftware Engineering Essentials

Objectives
In this session, you will learn to:

Create
Create
Create
Create

NIIT Ltd.

the
the
the
the

Sequence diagram
Communication diagram
State Machine diagram
Activity diagram

Page 1 of 23

oftware Engineering Essentials

Case Study: StarLine


Airways
Ticket Reservation Functionality

Page 2 of 23

oftware Engineering Essentials


Ticket Reservation Functionality
On receiving a request for reservation from a customer, the
counter assistant:

Accepts the date, departure city, and destination city from the
person and checks for the availability of a seat on the requested
date.
Maintains details about the availability of seats and the seat in the
Reservation file.
Confirms the details with the prospective passenger and accepts the
remaining details.
Updates the seat availability status in the Reservation file and adds
the passenger
details to the Manifest file. The passenger is assigned a unique
Passenger Name Request (PNR) number.
Prints the ticket and gives it to the
passenger.
Collects the fare amount from the passenger.
Updates the Daily Collection file.
NIIT Ltd.

Page 3 of 23

oftware Engineering Essentials


Ticket Reservation Functionality (Contd.)
StarLine Airways also provides overbooked or wait-listed
tickets.
Overbooking is allowed for 10 seats per flight.
For example, if the capacity of an aircraft is 340 seats,
bookings are made for 350 seats, that is, 340 seats plus 10
overbooked tickets.
An overbooked or wait-listed passenger is accommodated on
the flight depending on the availability of a seat when the
passenger checks in.
A passenger who cannot be accommodated on the flight is
given full refund.

NIIT Ltd.

Page 4 of 23

oftware Engineering Essentials

Creating the Sequence Diagra

Page 5 of 23

oftware Engineering Essentials


Creating the Sequence Diagram
Sequence diagrams represent interactions between objects in
the form of messages ordered in a sequence by time.
Let us create a sequence diagram for the Reserve Tickets use
case.
The following table lists the various classes and their
responsibilities
in realizing
the Reserve Tickets use case.
Class/Actor
Responsibilities
Customer
UI
Flight
Flight Reservation
Ticket

Enters date, sector, and class to check for a flight.


Enters booking details.
Accepts the flight details and initiates the method
for checking available flights for the provided
sector.
Checks the availability of seats for every flight.
Returns the list of available seats for every flight.
Updates the passenger details in the database.
Calculates the payment to be made for the ticket
booking.
Updates the list of available seats.

Passenger
NIIT Ltd.

Tells the system interface that the ticket booking is


complete.
Accepts the details of the passenger.
Page 6 of 23

oftware Engineering Essentials


Discussion
Discuss and identify the functionality of the Reserve Tickets
use case in detail. You may use the class diagram shown
below to consider the messages that will be exchanged
Ticket
between
objects.
Passenger
-PassengerName: string
-Age: int
-Address: string
-Contact_no: long
-Seat_preference: string
-Meal_preference: string
-Gender: char
-SSR: string

-PNR_no: long
-Ticket_no: int
-Date_of_issue: date
-Status: string
-Class: string

+getPassengerDetails()
+setPassengerDetails()
+validateDetails()

+bookTicket()
-printTicket()
+cancelTicket()
+printCancellationReceipt()
-processPayment()
-processRefund()
+checkReservationStatus()
+updateReservationStatus()

Flight Reservation

-Flight_no: string
-Date_of_flight: date
-Businessclass_availableseats: int
-Economyclass_availableseats: int
+updateSeatAvailability()
+checkSeatAvailability()
1

Flight

Aircraft
-Aircraft_name: string
-Totalseats_businessclass: int
-Totalseats_economyclass: int
+getAircraftDetails()
+setAircraftDetails()

-Flight_no: int
-From_city: string
-To_city: string
-Departure_time: time
-Arrival_time: time
-Days_of_flight: string
-Businessclass_fare: float
-Economyclass_fare: float
+getFlightDetails()
+setFlightDetails()
+matchSector()

NIIT Ltd.

Page 7 of 23

oftware Engineering Essentials


Sequence Diagram for Reserve Tickets Use Case
The following figure shows the sequence diagram for the
Reserve Tickets use case.
UI

F : Flight

: Customer
1 : Enter Date, Sector, Class

FR : Flight Reservation

T : Ticket

P : Passenger

loop for each flight


2 : matchSector()
opt if sector matches

3 : checkSeatAvailability()
4 : Available Seats

5 : Flight Details
6 : Enter Booking Details
7 : bookTicket()

8 : setPassengerDetails()
9 : processPayment()

10 : updateSeatAvailability()

11 : Ticket Booked

NIIT Ltd.

Page 8 of 23

oftware Engineering Essentials

ating the Communication Diag

Page 9 of 23

oftware Engineering Essentials


Discussion
Compare and contrast the sequence and communication
diagrams.
Based on the sequence diagram created by you, create a
communication diagram for the ticket reservation use case.

NIIT Ltd.

Page 10 of 23

oftware Engineering Essentials


Creating the Communication Diagram
Communication diagrams represent the interaction among
objects in the form of messages.
The following figure shows the communication diagram of the
Reserve Tickets use case.
P : Passenger

8 : setPassengerDetails()

10 : updateSeatAvailability()
9 : processPayment()
T : Ticket

7 : bookTicket()

FR : Flight Reservation

11 : Ticket Booked

1 : Enter Date, Sector, Class

4 : Available Seats

2 *[for each flight] : matchSector()


UI

: Customer
6 : Enter Booking Details

NIIT Ltd.

3 [if sector matches] : checkSeatAvailability()

F : Flight

5 : Flight Details

Page 11 of 23

oftware Engineering Essentials

ating the State Machine Diagr

Page 12 of 23

oftware Engineering Essentials


Creating the State Machine Diagram
A state machine diagram represents the various states that
an object may attain during its life cycle, in response to
various events.
In this case, let us create a state machine diagram for the
Ticket object.

NIIT Ltd.

Page 13 of 23

oftware Engineering Essentials


Discussion
Discuss and identify the various states that can be attained
by the Ticket object.

NIIT Ltd.

Page 14 of 23

oftware Engineering Essentials


Identifying the States
The following states can be attained by the Ticket object:

Waiting

Confirmed

Cancelled

NIIT Ltd.

Page 15 of 23

oftware Engineering Essentials


Identifying the Transitions
The following transitions take place in the state machine
diagram:
When a system user tries to book a ticket, the state of the Ticket
object is set to:
Waiting, if the required seats are not available.
Confirmed, if the required seats are available.

Later, if the seat for a wait-listed ticket becomes available, the


state of the Ticket object changes from Waiting to Confirmed.
If a wait-listed ticket is cancelled, the state changes from Waiting
to Cancelled.
If a confirmed ticket is cancelled, the state changes from
Confirmed to Cancelled.
From the Cancelled and Confirmed states the object goes to the
final state.

NIIT Ltd.

Page 16 of 23

oftware Engineering Essentials


Discussion
Based on the states and transitions identified, create a state
machine diagram for the Ticket object.

NIIT Ltd.

Page 17 of 23

oftware Engineering Essentials


State Machine Diagram for the Ticket Object
The following figure shows a possible state machine diagram
for the Ticket object.

Seat available

Seat not available


Waiting

Confirmed
Seat available

Cancel ticket

Cancel ticket

Cancelled

NIIT Ltd.

Page 18 of 23

oftware Engineering Essentials

Creating the Activity Diagram

Page 19 of 23

oftware Engineering Essentials


Creating the Activity Diagram
An activity diagram depicts the flow of control for a particular
process.
The process of booking a ticket will constitute the following
actions:
Accept date,
sector, and class.

Update
reservation
details in the
database.

Ticket
Booking

Check whether
the required
seats/ flights are
available.

Initiate the payment process for


the booking.

NIIT Ltd.

Page 20 of 23

oftware Engineering Essentials


Discussion
Discuss and create an activity diagram for the Reserve
Tickets use case.

NIIT Ltd.

Page 21 of 23

oftware Engineering Essentials


Activity Diagram for the Reserve Tickets Use Case
The following figure shows the activity diagram for the
Reserve Tickets use case.
Accept
Date,
Sector,
Class

Check
Booking
Availability

[ Booking Not Available ]

[ Booking Available ]

Accept
Booking
Details

Process
Payment

Update
Reservation
Details

NIIT Ltd.

Page 22 of 23

oftware Engineering Essentials


Summary
In this session, you learned that:
Sequence diagrams represent interactions between objects in the
form of messages ordered in a sequence by time.
Communication diagrams represent the interaction among objects
in the form of messages.
A state machine diagram represents the various states that an
object may attain during its lifecycle, in response to various
events.
An activity diagram depicts the flow of control for a particular
process.

NIIT Ltd.

Page 23 of 23

Vous aimerez peut-être aussi