Skip to content

Project Report Deliverable 3

Siger Ma edited this page Apr 13, 2022 · 1 revision

Deliverable 3

State Machine Behaviour

The following diagram describes our state machines.

To meet the specifications of Deliverable 3, we developed two state machines: one for Guide and one for Member.  image

State Machine for Guide

image

In the Guide state machine, a guide starts at the Available state. A guide remains in the Available state when they still have available slots in their schedule.

There is a transition from Available to Available. This transition is invoked for every guide to allow the guide to be assigned to members when we initiate the assignment process. The transition executes the action doBookGuide() to assign all possible members to the guide.

If a guide's available period is less than or equal to 0 days (checked with the availableForPeriod() <= 0 guard), the guide's schedule is completely booked, and we transition to the Taken state.

State Machine for Member

image

A member first starts in the Unassigned state. After we initiate the assignment process, the transition bookGuide() will trigger the assign(Guide guide) event and transition the member to the Assigned state if the member is successfully assigned to a schedule (check with the doAssign(guide) guard).

Assigned State

Usage: State for members who are assigned a schedule or a guide if booked

When a member is in the Assigned state and decides to:

  • cancel their trip, we trigger the cancelTrip event and transition to the Cancelled state for the member.
  • when a member is still in the Assigned state on their scheduled start day, we trigger the startTrip event, and the member transition's to the Banned state as they did not pay on the deadline.
  • pay for their trip, we trigger the confirmPayment event, and transition to the Paid state if the payment is approved.

Paid State

Usage: State for members that have fully paid for their trip.

When a member is in the Paid state:

  • decides to cancel their trip, we trigger the cancelTrip event and transition to the Cancelled state.
  • we trigger the startTrip(int day) event if the current diving day corresponds to the member's scheduled start day and transition to the Started state.

Started State

Usage: State for members who have started their trip

When a member is in the Started state:

  • decides to cancel their trip, we trigger the cancelTrip event and the member goes to the Cancelled state.
  • when the member has finished their trip, we trigger the finishTrip event and transition to the Finished state.

Finished State

Usage: State for members who have finished their trip

Cancelled State

Usage: State for members who decide to cancel their trip

*Note: The percentage refunded to members who cancel their trip is handled during the cancelTrip event and enforced in the Assignment controller.

Banned State

Usage: State for members who are banned for not paying their trip on time.

*Note: The toggle for ban is handled by the transition from Assigned state to Banned state.

Extra Methods

  • doAssign(Guide guide): Assign a member to a guide if needed and to a schedule. Returns a boolean to determine if member has been assigned a schedule.
  • doBookGuide(): Method for the guides to be booked and be assigned to members. It will call the transition assign(guide) on every member until the guide is taken or no more association is possible.
  • availableForPeriod(): Counts the number of days in which the guides still have availability.

Clone this wiki locally