L16Exercise MovieShopSMD
L16Exercise MovieShopSMD
Section
set #enrolled=0
registrationClosed
Available
[#enrolled≥10]
addStudent / register(student) Offered
dropStudent / unregister(student)
registrationClosed when(#enrolled=40)
[#enrolled<10]
Canceled
Full
do / unregister(all) dropStudent / unregister(student) registrationClosed
do / deleteSchedule
do / delete(self)
EXERCISE: STATE MACHINE DIAGRAM
Part of the information kept in the RentalCopy class in the domain model
shown below is the rental status of a movie. Construct a state machine
diagram showing the states that an instance of the RentalCopy class can be
in with respect to its rental status. Show only the states, transitions and the
events and/or conditions, if any, that cause a transition to be taken. Do not
show the activities that can occur within a state.
1 HasPhysical * 0..5
Movie RentalCopy
1
1 * copyNumber
returnDate
status
*
Reserves
HasPurchase HasRental
RentsPhysical
Reviews
* 0..1
* * Has 1
Rental Customer
* * Makes 1
Purchase
Member
0..1
EXERCISE: STATE MACHINE DIAGRAM
The problem statement requirements that could be relevant to determining
the states of a RentalCopy object:
It must be able to record which movies are sold and rented and by
whom.
For sold movies, the quantity sold should be recorded; for physical
movie rental, which copy is rented and when it is due back should be
recorded.
The system should keep track of overdue rentals of physical movies and
send email notices to customers who have movies overdue.
Members should be able to make reservations for physical movie rentals
either in person at the shop, by telephone or via the Web.
A member can reserve at most five physical movies at any one time, but
there is no limit on how many physical movies a member or nonmember
can rent at any one time.
A sales clerk should be able to sell and rent physical movies and
process the return of rented physical movies.
EXERCISE: STATE MACHINE DIAGRAM—ANALYSIS
It must be able to record which movies are sold and rented and by whom.
states: Available; Rented
events: rent
transitions: Available → rent → Rented
For sold movies, the quantity sold should be recorded; for physical movie rental,
which copy is rented and when it is due back should be recorded.
No new state, event or transition information in this statement.
The system should keep track of overdue rentals of physical movies and send
email notices to customers who have movies overdue.
states: Overdue
events: when(date>returnDate)
transitions: Rented → when(date>returnDate) → Overdue
actions: send overdue notice
EXERCISE: STATE MACHINE DIAGRAM—ANALYSIS
Members should be able to make reservations for physical movie rentals either in
person at the shop, by telephone or via the Web.
states: Reserved
events: reserve
transitions: Available → reserve → Reserved
Reserved → rent → Rented
A member can reserve at most five physical movies at any one time, but there is
no limit on how many physical movies a member or nonmember can rent at any
one time.
No state, event or transition information in this statement.
A sales clerk should be able to sell and rent physical movies and process the
return of rented physical movies.
event: return
transitions: Rented → return → Available
Overdue → return → Available
EXERCISE: STATE MACHINE DIAGRAM—ANALYSIS
Other reasonable events and transitions (but not explicitly stated)
events: cancel, delete
transitions: Reserved → cancel → Available
Available → delete → Final state
EXERCISE: STATE MACHINE DIAGRAM—SOLUTION
RentalCopy
Reserved
reserve rent
cancel
rent
Available Rented
return
return
delete
Overdue
when(date > returnDate) /
send overdue notice
EXERCISE: STATE MACHINE DIAGRAM—SOLUTION
Unavailable
Reserved
reserve cancel rent
rent
Available Rented
return
return
delete
Overdue
when(date>returnDate)
Missing/incorrect transitions.
e.g., an overdue video is not destroyed! It can be returned.