Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 SEQUENCE DIAGRAM EXAMPLE Part of the information kept in the RentalCopy class in the domain model shown below is the rental status of a video. Construct.

Similar presentations


Presentation on theme: "1 SEQUENCE DIAGRAM EXAMPLE Part of the information kept in the RentalCopy class in the domain model shown below is the rental status of a video. Construct."— Presentation transcript:

1 1 SEQUENCE DIAGRAM EXAMPLE Part of the information kept in the RentalCopy class in the domain model shown below is the rental status of a video. 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. Has 0..* RentalHistoryIsFor 1* Provides Reserves 1 * * * 1 * * 0..5 0..1 Buys quantity ReviewCustomer Member RentalCopyMovieVideo CurrentRental * 1

2 2 STATE MACHINE DIAGRAM EXAMPLE The problem statement requirements that are relevant to determining the states of a RentalCopy object: – The system must be able to keep track of which movie videos have been bought/rented and by whom. For videos bought, the system must record the quantity bought; for videos rented, the system must record which copy of the video has been rented and when it is due back. – The system must keep track of overdue rental videos and allow notices to be sent to customers who have videos overdue. – Members should be able to make reservations for movie video rentals either in person at the store, by telephone or via the Web. – A member can reserve at most five movie videos at any one time, but there is no limit on how many movie videos a member or nonmember can rent at any one time. – Staff must be able to sell/rent videos from the stores inventory and return rented videos to the store's inventory.

3 3 STATE MACHINE DIAGRAM EXAMPLE:ANALYSIS – The system must be able to keep track of which movie videos have been bought/rented and by whom. For videos bought, the system must record the quantity bought; for videos rented, the system must record which copy of the video has been rented and when it is due back. states: Available; Rented events: rent transitions: Available  rent  Rented – The system must keep track of overdue rental videos and allow notices to be sent to customers who have videos overdue. states: Overdue events: when(date>returnDate) transitions: Rented  when(date>returnDate)  Overdue – Members should be able to make reservations for movie video rentals either in person at the store, by telephone or via the Web. states: Reserved events: reserve transitions: Available  reserve  Reserved Reserved  rent  Rented

4 4 STATE MACHIINE DIIAGRAM EXAMPLE:ANALYSIS – A member can reserve at most five movie videos at any one time, but there is no limit on how many movie videos a member or nonmember can rent at any one time. No state, event or transition information in this statement. – Staff must be able to sell/rent videos from the stores inventory and return rented videos to the store's inventory. event: return transitions: Rented  return  Available Overdue  return  Available Other reasonable events and transitions events: cancel, delete transitions: Reserved  cancel  Available Available  delete  Final state

5 5 STATE MACHIINE DIIAGRAM EXAMPLE:SOLUTION

6 6 We can also create a composite state Unavailable.

7 7 STATE MACHINE DIAGRAM :COMMON ERRORS Showing flow of control. (A state machine is not a flow chart!) see Activity Diagrams. Showing states/transitions/events not applicable to the object under consideration. e.g., reservedCopy < 5  applies to Member objects,not RentalCopy objects Mixing up states and events. e.g., return is not a state Having transitions with no events. Having transitions with several events.

8 8 STATE MACHINE DIAGRAM :COMMON ERRORS Using attributes not in the object. e.g., #copies Having states with no outgoing transition. e.g., Overdue, Reserved Using states not in the problem description. e.g., stolen, sold, lost


Download ppt "1 SEQUENCE DIAGRAM EXAMPLE Part of the information kept in the RentalCopy class in the domain model shown below is the rental status of a video. Construct."

Similar presentations


Ads by Google