NFA Vending Machine Simulation Steven Stockall Intro NFANondeterministic

  • Slides: 7
Download presentation
NFA: Vending Machine Simulation Steven Stockall

NFA: Vending Machine Simulation Steven Stockall

Intro • NFA-Nondeterministic Finite Automaton - several possible states from current state, type of

Intro • NFA-Nondeterministic Finite Automaton - several possible states from current state, type of finite state machine • Goals: – Create a function NFA that works in a simulation – Gain a greater understanding to the use of and applications for finite state machines • Applications: – Vending Machine – Elevator – Circuit hardware

Design • Machine accepts dimes, nickels, and quarters – Monetary cap of $1 –

Design • Machine accepts dimes, nickels, and quarters – Monetary cap of $1 – Monetary states for all valid change inputs • Several purchase options: – Purchase items will vary in price – Invalid selections will return to current monetary state with prompt stating invalid selection – Valid selections will drop item and return correct change • ‘coin return’ button: – Returns change • Overflow: – Monertary input over $1 will be handled with an overflow state, this returns the amount of change equal to the amount over $1 entered into the machine by the user

Design (cont. ) • Code: – Design will be implemented in C# – Design

Design (cont. ) • Code: – Design will be implemented in C# – Design will have a small user interactive window with which the user can interact with and test the program

Code Organization • Main that starts the core program • Core: – Program starts

Code Organization • Main that starts the core program • Core: – Program starts with a $. 00 state – based on user input will call one of the modules passing in the user input and the old state – modules will return new state • Module that handles monetary selection: – overflow will be handled within module • Module that handles item selection: – invalid selections return same state – valid selections return item adjust change amount and returns remaining change then returns to $. 00 state • Module that handles coin return: – Returns coins – Returns to $. 00 state

Testing • Correct State transition: – test to check state to state transition •

Testing • Correct State transition: – test to check state to state transition • Correct State chaining: – test to check state transitions are correct for long transition chains • Correct input handling: – Buttons work properly • Correct cash overflow handling: – purposely test all possible overflow states

Conclusion • Goals: – will be to see how a NFA works in real

Conclusion • Goals: – will be to see how a NFA works in real world applications – create a functioning NFA – create a workable vending machine simulation