Answered step by step
Verified Expert Solution
Question
1 Approved Answer
in python please Assignment 7 A: Finite State Automata. In computer architecture ( a class you might take in the future ) we teach a
in python please
Assignment A: Finite State Automata.
In computer architecture a class you might take in the future we teach a concept called Finite
State Automata Also known as State Machines these models show different states of a
system and how you can move from one to other. We are going to simulate one using objects.
First, review the following diagram:
You will create a FSA class with one attribute: int state. The valid states are shown in the
diagram above. It should also have the following methods:
constructor: Takes in one integer for the state attribute. If the state is not one of the values
shown, it should be initialized to and the constructor should print out This is an invalid
state. Starting at state
int goToNextState: Takes in no parameters and advances the state variable to the next
state based on the diagram above. It should then return the state variable. It should not
print anything.
boolBoolean end: Takes in no parameters. It returns TRUE if the state is currently
and returns FALSE otherwise.
You will then create a separate class and file AssignmentA In its main method, you
should do the following:
Prompt the user to enter a state
Create a new FSA object using the constructor
Create a loop and prompt the user with two choices
Go to next state This should call the goToNextState function on the FSA
object and print the current state based on the value returned from the
function
End This should call the end function. If the returned value is TRUE, end
the loop and program. Otherwise, tell the user they can only end the program
at state
Sample Output:
Finite State Automata
What state do you want to start at
What will you do
Go to next state
End
Go to next state
Youre now at state
What will you do
Go to next state
End
END
You cant stop here; you can only stop at state
What will you do
Go to next state
End
Stop
Invalid command!
What will you do
Go to next state
End
Go to NEXT state
Youre now at state
What will you do
Go to next state
End
End
The FSA has shut down.
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