Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Task 1 (5 points): draw the finite automaton to represent the vending machine operations. Here you can find some free tools for you to draw
- Task 1 (5 points): draw the finite automaton to represent the vending machine operations. Here you can find some free tools for you to draw finite state machines: Link
- Task 2 (5 points): in the above given example, we need to modify the "refunding" state transition such that it requires the refunded money to be removed in order to move to the "ready" state, so the modified transition is defined as such: refunding -> remove -> ready. You are required to modify the given Java program to implement the updated transition.
- Task 3 (5 points): A turnstile, used to control access to subways and amusement park rides, is a gate with three rotating arms at waist height, one across the entryway. Initially the arms are locked, blocking the entry, preventing patrons from passing through. Depositing a coin or token in a slot on the turnstile unlocks the arms, allowing a single customer to push through. After the customer passes through, the arms are locked again until another coin is inserted. In this task, you are required to draw the finite automaton to represent the turnstile operations.
- Task 4 (25 points): implement a finite state machine which handles the turnstile transitions. Your program should have testing code to show how it works. You may choose to use unit testing or just use a main method for the testing purpose.
sample code :
import java.util.*; public class VendingMachine { private enum state { Ready(true, "Deposit", "Quit"), Waiting(true, "Select", "Refund"), Dispensing(true,"Remove"), Refunding(false, "Refunding"), Exiting(false, "Quiting"); state(boolean exp, string... in) { inputs = Arrays.aslist(in); explicit = exp; } state nextstate(String input, state current) { if (inputs.contains(input)) { return map.getOrDefault(input, current); } return current; } final List
Step 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