00:01
We're asked to construct a finite state machine for entering a security code into an atm.
00:08
We're told the rules for the atm is that the user enters a string of four digits, one digit at a time, that if the user enters the correct four digits, the password, the atm displays a welcome screen, and that when the user enters an incorrect number or an incorrect string of four digits, then the atm displays a screen that tells the user that an incorrect password was entered.
00:37
And finally, if a user enters the incorrect password three times, we're told that the account is going to be locked.
00:48
So consider the inputs.
00:53
Let's call the correct four -digit password abcd and let w -a, wb, w -b, wc, and w -d represent digits, other than a, b, c, or d, respectively.
02:00
And finally, let w represent any digit being entered.
02:17
So we have a few different inputs here.
02:24
Now, let's consider 22 states, s0, s1, s2, all the way up to s21.
02:36
And we'll see why there's so many of these in just a second.
02:46
Of course, s0 is going to represent the fact, well, it's the start state.
03:03
Now, we have that s4 is going to represent the correct code has been entered.
03:10
Some sort of skipping around here, sort of show the important states here.
03:26
And s21, the very last state, is going to represent that the account is locked.
03:52
Now the first attempt, so four digits, is going to use states s0, s1, s2, s3, and then s5, s6, s7, where s5, s6, and s7, we're going to represent that a wrong digit was entered in the code.
04:56
So, again, we're going to start from s0.
04:59
Now suppose that a wrong digit is entered at s0.
05:20
Then we're going to move to s5.
05:28
Now suppose that instead, the correct digit is entered at s0...