/*Use class FSMException as parent class to other exception classes. Keep exception classes protected so that they can be in the same file.*/ /*Create parent class*/ class FSMException extends Exception { /*Create constructors.*/ FSMException(){} FSMException(String s) {} } /*Class to prevent duplicate transitions from being created.*/ class DuplicateTransition extends FSMException { public DuplicateTransition() { super(); } public DuplicateTransition(String s) { super(s); } } /*Class that prevents simulation from beginning because the FiniteStateMachine is not valid (i.e. does not have an initial state)*/ class FSMNotValidException extends FSMException { FSMNotValidException() { super("Finite State Machine is not valid."); } } /*Class that warns that the transition being acted on does not exist.*/ class NoSuchTransition extends FSMException { public NoSuchTransition() { super(); } public NoSuchTransition(String s) { super(s); } } /*Class that prevents modifying the machine while a simulation is running.*/ class SimulationRunningException extends FSMException { SimulationRunningException(String function) { super("Cannot run " + function + " while simulation is running."); } } /*Class that prevents Events from being given when simulation is stopped.*/ class SimulationStoppedException extends FSMException { SimulationStoppedException(String function) { super("Cannot run " + function + " while simulation is stopped."); } } /*Class that prevents state from being acted on when it does not exist*/ class StateDoesNotExistException extends FSMException { StateDoesNotExistException(String stateName) { super(stateName + "state does not exist."); } } /*Class that prevents state from being created if it already exists.*/ class StateExistsException extends FSMException { StateExistsException(String stateName) { super("State " + stateName + " already exists."); } } /*Class that prevents state from being deleted if other transitions are pointing to it. This could also be dealt with by deleting all transitions pointing to state. We decided that affecting other states would not be the intention of the user, so the transitions must be deleted first.*/ class TransitionPointsToStateException extends FSMException { TransitionPointsToStateException() { super("Cannot delete state. Transition(s) point to this state."); } } /*Class to catch null pointers*/ class NullValueException extends FSMException { NullValueException(String s) { super(s); } }