00:01
Okay, for this problem, they'd like us to create a class that simulates an atm machine.
00:07
They want us to use the account class that we created back in chapter 7.
00:13
And essentially, what they'd like to do is just prompt for an account id.
00:19
Once we have an account id, it brings up a list of menu options, including check balance, withdraw, deposit, or exit.
00:28
If you exit, it goes back to prompting for an account.
00:30
Account id and it just runs in a loop forever.
00:35
So essentially the only member variable that this atm class is going to have is this list of accounts.
00:44
So i will go ahead and visualize that as an empty list.
00:49
I'm also going to add a type hint just to add auto complete options, typing a little bit easier.
01:01
In our initializer, we're going to have it just create 10 accounts with $100 each.
01:11
So we'll just iterate over a range 10.
01:26
Create new account, the id equal to i, and we will set the balance equal to 100.
01:43
Now for our account function function, function.
01:55
Let's call this prompt option.
02:00
So we should also call prompt menu or something like that.
02:03
At this point, we want to already have the account id.
02:09
And so while the user is logged in for say, we're going to exit directly out from the wild loop.
02:22
So we're just going to make this an infinite loop.
02:25
We want to prompt for an option.
02:34
Let's see, they've given us a menu here, which i'm just going to copy over that.
02:45
We're using a multi -line string so that the new lines will get printed out as well.
02:54
And if the option is equal to option one, we're going to just print the balance.
03:05
So balance is that variable to float.
03:11
And we want it to print just two decimal places since it's in dollars.
03:23
We're going to fetch the correct account here and get the balance.
03:38
Next is option two, which is to withdraw money.
03:53
So if they select option two, we're going to prompt them for an amount to withdraw.
03:59
Okay, once we have that, we can just call the withdraw function on the correct account.
04:28
For option three, we're just going to do a deposit, which is going to be basically the same as option two.
04:37
The opposite.
04:48
Deposit here, call the deposit function instead of withdraw.
04:56
Option four is simply to exit or log out of the machine, for which we can just protect.
05:07
Turn to the previous task...