Question: 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 7 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 0 and the constructor should print out This is an invalid
state. Starting at state 0
01
32
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.
bool/Boolean end(): Takes in no parameters. It returns TRUE if the state is currently 3,
and returns FALSE otherwise.
You will then create a separate class (and file), Assignment7A. 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 3.
Sample Output:
[Finite State Automata]
What state do you want to start at?1
What will you do?
>Go to next state
>End
Go to next state
Youre now at state 2.
What will you do?
>Go to next state
>End
END
You cant stop here; you can only stop at state 3.
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 3.
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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!