1 00:00:05,460 --> 00:00:09,009 Welcome back, I hope you enjoyed the section 15 challenge. 2 00:00:09,469 --> 00:00:12,150 I'm going to give you my solution here, and we'll walk through it. 3 00:00:12,570 --> 00:00:15,310 As always, there's a lot of different ways to do this. 4 00:00:15,310 --> 00:00:19,060 So if your solution is different from mine, it's probably just fine. 5 00:00:19,490 --> 00:00:23,000 So I'm in the section 15 workspace in the ChallengeSolution project. 6 00:00:23,180 --> 00:00:27,270 So I didn't change the account or the savings account classes at all. 7 00:00:27,460 --> 00:00:29,619 So why don't we start with the checking account class. 8 00:00:29,639 --> 00:00:31,429 This is one of the new classes that we added. 9 00:00:31,750 --> 00:00:34,709 So let me open up the checking account header file, and let's 10 00:00:34,709 --> 00:00:35,909 go through this real quickly. 11 00:00:36,410 --> 00:00:40,850 Now in this case, the checking account doesn't add any new attributes, right. 12 00:00:41,060 --> 00:00:43,050 So a checking account is an account. 13 00:00:43,090 --> 00:00:46,580 I chose to derive this from account because the checking account has 14 00:00:46,580 --> 00:00:48,199 the name and it's got a balance. 15 00:00:48,530 --> 00:00:51,250 The only difference here is that when we withdraw, we're doing 16 00:00:51,250 --> 00:00:53,939 a $1.50 flat fee, check fee. 17 00:00:54,390 --> 00:00:57,900 Okay, so other than that it's really, really very similar. 18 00:00:57,910 --> 00:01:02,030 We've got our const expressions here, which are just our 19 00:01:02,280 --> 00:01:03,640 compile time constants. 20 00:01:04,138 --> 00:01:07,320 Here we've got our constructor that expects a name. 21 00:01:07,750 --> 00:01:12,120 And if it's not supplied, we'll use our default here, a balance. 22 00:01:12,809 --> 00:01:13,650 And that's it, right. 23 00:01:13,650 --> 00:01:16,419 The per check fee is not a per object thing. 24 00:01:16,650 --> 00:01:17,920 This is a class thing. 25 00:01:18,160 --> 00:01:20,320 So this is why it's a static cost expression. 26 00:01:20,789 --> 00:01:24,679 If it was on a per account basis and obviously you'd want that to 27 00:01:24,679 --> 00:01:26,930 be an attribute and you'd want to pass it into a constructor. 28 00:01:28,219 --> 00:01:29,589 So we've got that. 29 00:01:29,660 --> 00:01:33,080 We've got our withdraw method because we need to override 30 00:01:33,090 --> 00:01:35,670 the behavior for withdraw to deal with the per check fee. 31 00:01:36,400 --> 00:01:38,350 The deposit method is fine. 32 00:01:38,370 --> 00:01:40,360 We don't need to change that at all because the way we do 33 00:01:40,360 --> 00:01:43,360 deposits is the same way that an account does a deposit. 34 00:01:43,730 --> 00:01:47,289 Hopefully, one of the things that you notice when you derive these classes 35 00:01:47,289 --> 00:01:50,450 from existing classes is the amount of code you have to write is really 36 00:01:50,450 --> 00:01:54,080 minimal in many cases, right, because all you're doing is specializing. 37 00:01:54,380 --> 00:01:58,309 The other thing we did here was we created that overloaded 38 00:01:58,309 --> 00:02:01,560 insertion operator that works with a checking account that just makes 39 00:02:01,560 --> 00:02:03,030 it really easy to display those. 40 00:02:03,469 --> 00:02:04,469 Okay, so that's it. 41 00:02:04,500 --> 00:02:06,119 Let’s take a look at the implementation. 42 00:02:07,309 --> 00:02:10,080 And as you can see, there's really very little code here. 43 00:02:10,590 --> 00:02:12,460 First of all, let's look at the constructor. 44 00:02:12,660 --> 00:02:14,480 So there's my checking account constructor. 45 00:02:14,480 --> 00:02:16,790 It expects the name and the balance. 46 00:02:17,380 --> 00:02:19,689 And I need to initialize the account part of me, right 47 00:02:19,690 --> 00:02:21,049 because I'm derived from account. 48 00:02:21,440 --> 00:02:25,289 So here I'm invoking my base classes constructor and it's the 49 00:02:25,289 --> 00:02:27,990 one that takes care of name and balance I'm just passing it over. 50 00:02:28,870 --> 00:02:31,370 And when this comes back, we're initialized, right. 51 00:02:32,210 --> 00:02:34,460 At that point, that's all. 52 00:02:34,460 --> 00:02:36,179 That's all we need for a constructor here. 53 00:02:36,910 --> 00:02:38,250 Now what about the withdraw method. 54 00:02:38,450 --> 00:02:41,490 Well, here we're definitely overriding the withdraw method. 55 00:02:41,550 --> 00:02:45,270 So here's the withdraw method for the new class my checking account class. 56 00:02:45,300 --> 00:02:47,309 It still expects an amount to withdraw. 57 00:02:47,730 --> 00:02:50,980 And all we're doing is we're saying okay whatever that amount is I'm 58 00:02:50,980 --> 00:02:54,440 just adding the per check fee to it, which is a 1.50 dollar in this case. 59 00:02:54,880 --> 00:02:57,974 So whatever, I want to withdraw I'm just adding the 1.50 dollar. 60 00:02:58,160 --> 00:03:01,210 And then I'm letting the account class do the withdrawal, 61 00:03:01,389 --> 00:03:02,510 just like we've done before. 62 00:03:02,510 --> 00:03:05,300 And again, I'm returning what it returns. 63 00:03:05,480 --> 00:03:07,520 So if it fails, I'll return false. 64 00:03:07,530 --> 00:03:09,500 If it succeeds, I'll return true. 65 00:03:10,860 --> 00:03:13,989 And then the last thing we'll do is our output operator 66 00:03:14,000 --> 00:03:15,600 here, our insertion operator. 67 00:03:16,059 --> 00:03:18,000 This time it expects a checking account. 68 00:03:18,539 --> 00:03:20,760 And actually we could have used used a regular account here, 69 00:03:20,760 --> 00:03:23,200 right because we're not really adding anything in this class. 70 00:03:23,200 --> 00:03:25,940 So even if it got sliced, it's okay because we're 71 00:03:25,940 --> 00:03:27,020 not adding anything at all. 72 00:03:27,490 --> 00:03:28,180 So that's it. 73 00:03:28,180 --> 00:03:30,720 That's a pretty simple implementation of that checking account. 74 00:03:30,720 --> 00:03:33,169 Now let's take a look at the trust account. 75 00:03:35,309 --> 00:03:37,100 So here we have our trust account. 76 00:03:37,520 --> 00:03:40,840 And you can see that the trust account is derived publicly 77 00:03:40,840 --> 00:03:42,100 from a savings account. 78 00:03:42,390 --> 00:03:44,990 And that's because a trust account has a name, a 79 00:03:44,990 --> 00:03:46,950 balance and an interest rate. 80 00:03:47,160 --> 00:03:50,540 So a lot of the savings account behavior will be perfect for that. 81 00:03:51,170 --> 00:03:55,239 I'm overloading the insertion operator here for a trust account as usual. 82 00:03:56,160 --> 00:03:58,280 And now this code looks a little lengthier. 83 00:03:58,280 --> 00:04:00,520 And the reason for that is all these constants here. 84 00:04:01,060 --> 00:04:01,940 They're handy, right. 85 00:04:01,940 --> 00:04:04,230 Here's our default balance, here's a default interest rate. 86 00:04:04,230 --> 00:04:07,800 You probably could make that 2 or 3% or something just 87 00:04:07,800 --> 00:04:09,969 to get some more interesting results, but I'll leave it at 0. 88 00:04:10,309 --> 00:04:13,510 There's the bonus amount for a deposit that's over 5000 dollars. 89 00:04:13,520 --> 00:04:14,930 There's the threshold that's 5000. 90 00:04:15,790 --> 00:04:18,510 The maximum withdrawals is 3, and the most we can withdraw 91 00:04:18,510 --> 00:04:20,610 is 20% of the accounts value. 92 00:04:20,849 --> 00:04:23,860 So all that information is right in here in these constants. 93 00:04:24,320 --> 00:04:28,039 And the only thing that the trust account really adds is 94 00:04:28,430 --> 00:04:31,340 besides the business logic, of course, is this attribute right 95 00:04:31,340 --> 00:04:32,740 here the number of withdrawals. 96 00:04:32,940 --> 00:04:36,590 So it will set that to 0 when we create a trust account object. 97 00:04:36,850 --> 00:04:39,159 And then every time we do a withdrawal, that's successful, 98 00:04:39,160 --> 00:04:40,160 we'll bump it up by 1. 99 00:04:40,670 --> 00:04:43,289 And then when we do a withdrawal and it's greater than 3, we'll just 100 00:04:43,290 --> 00:04:44,880 fail right there, pretty simple. 101 00:04:45,370 --> 00:04:46,849 Okay, so here's my constructor. 102 00:04:47,850 --> 00:04:51,310 It expects as usual, a name, a balance and an interest rate. 103 00:04:51,320 --> 00:04:52,350 You can see that right there. 104 00:04:52,350 --> 00:04:55,340 And it's got these defaults right up here that it defaults to. 105 00:04:56,630 --> 00:05:00,010 Here's my deposit, which I obviously need to override 106 00:05:00,010 --> 00:05:03,880 because I've get a 50 dollar whenever I deposit 5000 or more. 107 00:05:04,379 --> 00:05:07,280 And here's my withdrawal which again I need to override because our 108 00:05:07,280 --> 00:05:11,900 business logic says I'm only allowed maximum of 3 withdrawals per year, 109 00:05:12,400 --> 00:05:16,510 and each one is up to a maximum of 20% of the accounts value or balance. 110 00:05:17,469 --> 00:05:18,390 Okay, so that's it. 111 00:05:18,440 --> 00:05:21,970 Let's take a look at the implementation file now. 112 00:05:24,059 --> 00:05:26,289 And here's the implementation file for the trust account. 113 00:05:26,620 --> 00:05:28,530 You can see our constructor is up here. 114 00:05:29,530 --> 00:05:32,169 Again, we're receiving the name, the balance and the interest rate. 115 00:05:32,510 --> 00:05:37,179 And all of those guys are really in my savings account part, right. 116 00:05:37,410 --> 00:05:41,130 So I'm invoking my base class constructor right here, 117 00:05:41,410 --> 00:05:43,540 and I'm passing in name, balance and interest rate. 118 00:05:43,540 --> 00:05:45,540 Let it take care of initializing itself. 119 00:05:46,130 --> 00:05:48,940 When I come back, I do need to take care of my attribute, 120 00:05:48,960 --> 00:05:50,500 which is number of withdrawals. 121 00:05:50,750 --> 00:05:54,390 So this is my responsibility, and I'm setting that to 0 right here. 122 00:05:55,599 --> 00:05:57,890 Okay, so now let's take a look at the deposit. 123 00:05:58,240 --> 00:06:00,780 So here's the trust account deposit method. 124 00:06:00,810 --> 00:06:02,960 Again, it expects an amount. 125 00:06:03,480 --> 00:06:07,230 And all I'm looking for is that bonus threshold which is 5000 dollars. 126 00:06:07,440 --> 00:06:11,219 So if the amount deposited is greater than or equal to that bonus threshold, 127 00:06:11,219 --> 00:06:14,590 which in again in this case is 5000, then we're just incrementing 128 00:06:14,610 --> 00:06:18,139 the amount to deposit by the bonus amount which is the 50 dollars. 129 00:06:18,990 --> 00:06:24,230 Simple as that, I invoke my base classes deposit method because the 130 00:06:24,310 --> 00:06:27,709 savings account knows how to deal with the interest rate and the deposit. 131 00:06:27,980 --> 00:06:30,309 And I'm returning right here what it returns to me. 132 00:06:31,610 --> 00:06:34,890 And then the last thing we'll do is our withdraw method. 133 00:06:35,369 --> 00:06:37,789 Again, the withdraw method's important because it's got 134 00:06:37,790 --> 00:06:39,020 some business logic here. 135 00:06:39,240 --> 00:06:41,180 So I want to check -- and again, here's the amount 136 00:06:41,190 --> 00:06:42,180 that I want to withdraw. 137 00:06:42,650 --> 00:06:45,840 So if the number of withdrawals is greater than or equal to the 138 00:06:45,849 --> 00:06:51,020 max withdrawals, which was that constant, which was 3 or the amount 139 00:06:51,070 --> 00:06:54,269 to withdraw is greater than the balance times the threshold, right, 140 00:06:54,350 --> 00:06:56,250 so that's the 20% right here. 141 00:06:56,980 --> 00:07:00,039 If either one of those guys is true, we don't do the 142 00:07:00,350 --> 00:07:01,870 withdrawal, we return false. 143 00:07:02,150 --> 00:07:05,770 Otherwise, we increment the number of withdrawals, and we call our 144 00:07:05,770 --> 00:07:09,080 savings account withdraw method and pass in the account -- and 145 00:07:09,080 --> 00:07:10,880 pass in the amount to withdraw. 146 00:07:11,469 --> 00:07:12,169 So that's it. 147 00:07:12,170 --> 00:07:15,000 You can see that we really aren't writing a lot of new code. 148 00:07:15,000 --> 00:07:19,450 We're specializing, we're tweaking, we're refining if you will our 149 00:07:19,450 --> 00:07:21,570 behavior based on our business logic. 150 00:07:22,120 --> 00:07:25,810 And then the last thing is this overloaded insertion 151 00:07:25,810 --> 00:07:27,380 operator for trust account. 152 00:07:27,750 --> 00:07:31,990 In this case, I'm also displaying the number of withdrawals just 153 00:07:31,990 --> 00:07:33,479 so that we have that information. 154 00:07:34,070 --> 00:07:35,690 Okay, so that's the trust account. 155 00:07:35,740 --> 00:07:38,909 So we've got our two new accounts in the hierarchy now. 156 00:07:39,210 --> 00:07:42,979 So the next thing I want to show you is that account util file and the 157 00:07:43,049 --> 00:07:44,799 functions that I modified in there. 158 00:07:46,369 --> 00:07:49,729 So let's look at the changes I made to the account util files. 159 00:07:50,090 --> 00:07:55,650 And you can see that right here I've added the function prototypes 160 00:07:55,650 --> 00:07:59,320 for the checking account class and the trust account class. 161 00:07:59,630 --> 00:08:02,870 You can see that all this code is really, really, really similar. 162 00:08:03,290 --> 00:08:05,729 And you're going to love what's going to happen in the next section. 163 00:08:05,730 --> 00:08:07,460 We're going to be able to get rid of all of this and just 164 00:08:07,460 --> 00:08:10,860 create one version that works for all of the accounts once 165 00:08:10,860 --> 00:08:12,440 we use polymorphic functions. 166 00:08:12,730 --> 00:08:15,090 But for now, let's just do it this way so that we really 167 00:08:15,090 --> 00:08:16,180 understand what's going on. 168 00:08:16,389 --> 00:08:18,859 Again, remember, we're doing static binding right now. 169 00:08:18,860 --> 00:08:23,019 So the compiler is binding the method calls to the actual 170 00:08:23,049 --> 00:08:25,950 types of the objects that it sees in at compile time. 171 00:08:26,390 --> 00:08:28,930 So there are the function prototypes for these guys. 172 00:08:28,980 --> 00:08:30,830 It's very similar to what we did before. 173 00:08:31,330 --> 00:08:35,839 And the implementation file right here, same idea. 174 00:08:36,289 --> 00:08:37,929 I'll just scroll down just a little bit. 175 00:08:37,960 --> 00:08:41,799 And you can see here are the helper functions for the checking account 176 00:08:41,799 --> 00:08:43,190 class right here on line 64. 177 00:08:44,370 --> 00:08:47,600 And if we scroll down a little bit further, we've got the helper 178 00:08:47,600 --> 00:08:49,690 functions for the trust account class. 179 00:08:50,210 --> 00:08:54,460 And as I said, they're all exactly the same except what's inside that vector. 180 00:08:56,150 --> 00:08:57,979 Okay, so now let's look at the main. 181 00:08:58,010 --> 00:09:01,045 Finally, here's the main and the beginning is exactly the 182 00:09:01,045 --> 00:09:03,000 same as it was before, right. 183 00:09:03,030 --> 00:09:08,200 You remember we had the accounts tests right here, so we put in some account objects 184 00:09:08,500 --> 00:09:11,500 into a vector of accounts and then we call display, 185 00:09:11,500 --> 00:09:13,500 deposit and withdraw for those accounts. 186 00:09:13,500 --> 00:09:18,000 We did that both for a regular account and a savings account here. 187 00:09:18,000 --> 00:09:19,849 And now we're just going to do the same thing again 188 00:09:19,849 --> 00:09:20,760 for a checking account. 189 00:09:20,790 --> 00:09:23,830 So you can see here I'm creating a vector of checking 190 00:09:23,830 --> 00:09:25,090 account objects, right. 191 00:09:25,120 --> 00:09:27,500 That's my template argument right here, checking account, 192 00:09:28,230 --> 00:09:29,570 and it's check accounts. 193 00:09:30,080 --> 00:09:32,930 And I'm creating an empty checking account, one for Kirk, one for 194 00:09:32,930 --> 00:09:35,809 Spock and, one for Bones, let's say. 195 00:09:36,129 --> 00:09:37,690 I don't want to give Spock two accounts. 196 00:09:38,760 --> 00:09:40,670 And that's it. 197 00:09:40,770 --> 00:09:44,150 Then we're going to call display for check accounts, deposit a 1000 198 00:09:44,679 --> 00:09:47,220 into each one of those accounts and withdraw from those accounts 2000. 199 00:09:48,140 --> 00:09:50,130 And then finally, we're going to do the trust account. 200 00:09:50,350 --> 00:09:52,630 And the trust account, same idea. 201 00:09:53,070 --> 00:09:56,120 I'm going to have a vector of trust account objects. 202 00:09:56,680 --> 00:09:58,720 And I'm going to create four of them again. 203 00:09:59,570 --> 00:10:01,920 I'm going to construct this one with no initialization, 204 00:10:01,920 --> 00:10:03,040 just like I've done before. 205 00:10:03,380 --> 00:10:06,710 And then we'll create Athos, Porthos and Aramis, the three musketeers. 206 00:10:07,090 --> 00:10:08,850 And we'll create some accounts for them. 207 00:10:09,770 --> 00:10:12,829 We'll display them, deposit into them and withdraw from 208 00:10:12,830 --> 00:10:14,349 them, just like we did before. 209 00:10:14,750 --> 00:10:17,560 And then the last thing I'm doing is I'm simply calling 210 00:10:17,560 --> 00:10:18,689 withdrawal five times. 211 00:10:18,690 --> 00:10:21,040 So I'm looping five times, and I'm calling withdraw 212 00:10:21,450 --> 00:10:23,070 on those trust accounts. 213 00:10:23,080 --> 00:10:25,809 So I expect those to fail, right because I'm only allowed 214 00:10:25,809 --> 00:10:28,080 to withdraw 3 times maximum. 215 00:10:28,459 --> 00:10:31,310 And I can only withdraw 20% of the balance. 216 00:10:31,310 --> 00:10:33,349 So I should see a lot of failures here. 217 00:10:34,140 --> 00:10:35,530 So let's run this. 218 00:10:35,570 --> 00:10:37,630 And there's going to be a lot of output to go through. 219 00:10:39,770 --> 00:10:42,810 And you can see we have a clean compile, no errors, no warnings. 220 00:10:43,099 --> 00:10:45,979 And I'll scroll up here because there's a lot of output to go through. 221 00:10:46,520 --> 00:10:48,949 And this is what we had earlier, right. 222 00:10:48,949 --> 00:10:51,930 When we created just the regular accounts here, we created four 223 00:10:51,930 --> 00:10:55,710 of them: Larry, Moe Curly and an unnamed account right up top. 224 00:10:56,160 --> 00:10:57,240 We're going to display them. 225 00:10:57,260 --> 00:10:58,890 That's what you're seeing right here. 226 00:11:00,340 --> 00:11:02,510 Then we're going to deposit a 1000 into them. 227 00:11:02,510 --> 00:11:05,139 And that's this piece you see right here, depositing two accounts. 228 00:11:05,490 --> 00:11:07,710 And then we're withdrawing 2000 from them that's the 229 00:11:07,710 --> 00:11:09,020 piece you see right here. 230 00:11:09,360 --> 00:11:12,420 The first two fail because there's insufficient funds. 231 00:11:12,930 --> 00:11:14,100 So that's pretty straightforward. 232 00:11:14,290 --> 00:11:16,990 That's exactly what the default code was in the challenge. 233 00:11:17,309 --> 00:11:18,029 So is this. 234 00:11:18,030 --> 00:11:19,520 Here's my savings accounts. 235 00:11:19,900 --> 00:11:22,170 Let me just scroll up to so we can see that right here. 236 00:11:22,469 --> 00:11:25,260 So we're creating those four savings accounts for superman, 237 00:11:25,260 --> 00:11:26,380 batman and wonderwoman. 238 00:11:27,120 --> 00:11:27,810 There they are. 239 00:11:27,810 --> 00:11:31,030 When we display them, we're depositing a 1000 dollars into them here, 240 00:11:31,030 --> 00:11:32,710 and then we're withdrawing 2000. 241 00:11:32,990 --> 00:11:36,439 So of course, the first two will fail because there's insufficient 242 00:11:36,440 --> 00:11:37,520 funds, just like before. 243 00:11:38,150 --> 00:11:39,300 Now here's the checking. 244 00:11:39,549 --> 00:11:42,410 The checking is a little different now because our withdraw methods 245 00:11:42,529 --> 00:11:45,770 add a $1.50 service fee or a per check fee, right. 246 00:11:46,070 --> 00:11:50,959 So here we've got a checking account for an unnamed checking account. 247 00:11:51,389 --> 00:11:53,760 We've got Kirk, Spock and Bones. 248 00:11:54,009 --> 00:11:55,530 And you can see them right here. 249 00:11:56,589 --> 00:11:59,069 Right here is our display, right. 250 00:11:59,070 --> 00:12:01,990 There's our unnamed checking account with 0 balance. 251 00:12:02,290 --> 00:12:07,130 There's Kirk, 0 balance, Spock and Bones 2000 5000, respectively. 252 00:12:07,590 --> 00:12:10,130 I'm depositing a $1000 into each account. 253 00:12:11,130 --> 00:12:14,810 And then I'm going to withdraw 2000 from each account, exactly the 254 00:12:14,810 --> 00:12:16,320 same we've - as we've done before. 255 00:12:16,529 --> 00:12:17,929 So the first two are going to fail. 256 00:12:18,199 --> 00:12:20,720 And you can see that the numbers now are a little different right 257 00:12:20,720 --> 00:12:25,500 because we are subtracting the $1.50 per check fee here. 258 00:12:26,500 --> 00:12:28,579 And these two don't because the withdrawal failed. 259 00:12:28,580 --> 00:12:32,349 But in this case, we did withdraw so we're assessing the $1.50 fee. 260 00:12:33,150 --> 00:12:35,770 So you can see that indeed the specialized withdraw 261 00:12:35,799 --> 00:12:36,780 method is being called. 262 00:12:37,140 --> 00:12:39,090 Now finally, we've got the trust accounts. 263 00:12:39,090 --> 00:12:41,780 So there's our code for the trust account, and I'll scroll 264 00:12:41,780 --> 00:12:42,920 that up right about there. 265 00:12:43,640 --> 00:12:47,230 So here I'm creating Athos Porthos and Aramis and an unnamed trust 266 00:12:47,230 --> 00:12:48,850 account, right here at the beginning. 267 00:12:49,240 --> 00:12:54,040 And we're creating some different balances as well as interest rates. 268 00:12:55,109 --> 00:12:57,140 And then we're just displaying the accounts and that's what 269 00:12:57,140 --> 00:12:58,080 you're seeing here, right. 270 00:12:58,080 --> 00:13:01,530 The unnamed trust account with 0 balance 0% interest rate. 271 00:13:01,570 --> 00:13:02,819 It has no withdrawals yet. 272 00:13:03,450 --> 00:13:04,959 Here's Athos Porthos and Aramis. 273 00:13:04,959 --> 00:13:07,120 And you can see their information right here. 274 00:13:07,440 --> 00:13:10,080 Notice how all of them have 0 withdrawals because we 275 00:13:10,080 --> 00:13:11,960 set that in our constructor. 276 00:13:12,389 --> 00:13:14,479 Now we're going to call deposit on each one of them 277 00:13:14,479 --> 00:13:15,880 and deposit a 1000 dollars. 278 00:13:16,310 --> 00:13:18,470 You can see that that's successful all the way through. 279 00:13:19,630 --> 00:13:23,630 You can also see that we've got the bonus coming in here. 280 00:13:23,630 --> 00:13:25,900 So finally, we withdraw 3000 dollars from each account. 281 00:13:26,330 --> 00:13:29,319 The first two will fail the first one because we 282 00:13:29,319 --> 00:13:30,564 don't have sufficient funds. 283 00:13:31,060 --> 00:13:34,840 The second one because we are exceeding our 20% limit. 284 00:13:35,640 --> 00:13:37,900 But the third and fourth one are no problem at all. 285 00:13:37,900 --> 00:13:41,389 You notice the withdrawals here are now one whereas the withdrawals 286 00:13:41,400 --> 00:13:42,900 on the failed ones are 0. 287 00:13:44,440 --> 00:13:47,220 And then what I'm doing is I'm just calling that same 288 00:13:47,220 --> 00:13:49,240 withdraw function 5 times. 289 00:13:49,530 --> 00:13:51,550 So there's 1's right here. 290 00:13:51,690 --> 00:13:54,709 You can see the number of withdrawals increasing and increasing and 291 00:13:54,710 --> 00:13:58,500 finally, everything fails as we expect right here 292 00:13:58,500 --> 00:14:02,500 because we've exceeded the 3 withdrawals. 293 00:14:02,900 --> 00:14:04,230 Okay, so that's it. 294 00:14:04,340 --> 00:14:07,520 I'm sure your solution is different from mine, and that's okay. 295 00:14:08,250 --> 00:14:10,290 Take a look at my solution, maybe yours is better. 296 00:14:10,290 --> 00:14:11,349 If it's better, post it. 297 00:14:11,660 --> 00:14:15,300 If you find a bug in mine, let me know please, and I'll be glad to fix it. 298 00:14:15,510 --> 00:14:17,310 So I hope you enjoyed this challenge. 299 00:14:17,310 --> 00:14:19,180 I hope you understand a lot about inheritance. 300 00:14:19,820 --> 00:14:23,300 In the next section, we're going to crank up the level in inheritance, and 301 00:14:23,300 --> 00:14:27,660 we're going to talk about polymorphic functions with inheritance and that's 302 00:14:27,660 --> 00:14:29,400 going to make all of this even easier. 303 00:14:29,750 --> 00:14:31,000 So stay tuned for that.