Answered step by step
Verified Expert Solution
Question
1 Approved Answer
write the code in java state machine Bank ATM service Idle in(card) IS fixed cancel Out of Service Active The above figure is a simple
write the code in java
state machine Bank ATM service Idle in(card) IS fixed cancel Out of Service Active The above figure is a simple state diagram of a bank ATM. The ATM will be in one of the three states: Idle (default), Active and Out of Service. To implement the ATM's state machine: 1. Use a nested class, called StateMachine, inside the ATM class. 2. All events received by the ATM are delegated to the State Machine. These events are Service (), Fixed(), Cancel() and Incard(). 3. The ATM and the State Machine classes have references to each other (i.e. each class has a field of type the other class). 4. Inside the State Machine class, we use: a. Two Java enums: event and State i. The event enum represents all events. ii. The State enum represents all states in the state machine. 5.Declare a class called ATMTest that contains: a. A static void method called SendEvent() that accepts an event, decides which transition to execute and then prints the current state of the state machine. Hint: call Service (), Fixed(), Cancel() or InCard() methods. b. The main() method to test the SendEvent(). To answer the above mentioned questions, complete the followingStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started