80 likes | 170 Views
Construct a state machine diagram for RentalCopy class to show various states and transitions based on rental status. Includes problem statement requirements and analysis of states/events like Available, Rented, Overdue, Reserved, and more. Avoid common errors in creating state machine diagrams.
E N D
Buys quantity 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 RentalCopyclass 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 1 0..* 0..5 * MovieVideo RentalCopy 1 * * IsFor CurrentRental RentalHistory Reserves 1 * * Provides * 1 Review Customer * Member 0..1
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.
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
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
STATE MACHIINE DIIAGRAM EXAMPLE:SOLUTION We can also create a composite state Unavailable.
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 < 5applies 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.
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