Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,560 --> 00:00:05,870
Welcome to part four, going back to requirements text, a checking account is taxable.
2
00:00:05,990 --> 00:00:11,390
That means you can draw a line between checking vs. savings and loan by making checking taxable.
3
00:00:11,690 --> 00:00:15,200
In other words, by having, checking, implement the taxable interface.
4
00:00:15,650 --> 00:00:18,950
So inside taxable, we're going to create the method signature.
5
00:00:20,470 --> 00:00:24,470
For a tax method that expects an income parameter.
6
00:00:25,690 --> 00:00:31,330
OK, and now from checking, we're going to implement the taxable interface implements.
7
00:00:33,910 --> 00:00:34,600
Taxable.
8
00:00:39,930 --> 00:00:46,320
Remember that an interface is a contract of behavior, a class that implements an interface must override
9
00:00:46,320 --> 00:00:47,340
all of its methods.
10
00:00:47,730 --> 00:00:50,250
So in this case, we have to override tax.
11
00:00:54,060 --> 00:00:57,780
And before we do anything, we want to create a unit test for this piece of behavior.
12
00:00:59,330 --> 00:01:01,610
So back inside of account tests.
13
00:01:02,640 --> 00:01:07,650
We're going to create another unit test that test called income tax.
14
00:01:07,770 --> 00:01:10,890
Public void income tax.
15
00:01:11,880 --> 00:01:16,830
And we'll just assume that person's total income ended up being three thousand.
16
00:01:17,220 --> 00:01:18,600
So we'll just deposit that.
17
00:01:20,110 --> 00:01:21,700
Or, you know what, make it 4000.
18
00:01:22,960 --> 00:01:23,800
The president.
19
00:01:24,860 --> 00:01:30,770
Accounts at Index zero dark deposit 4000 into the checking account.
20
00:01:32,130 --> 00:01:40,830
And now, if you try to say accounts at index zero tax, you're not going to get any results because
21
00:01:40,830 --> 00:01:48,210
right now every element in the accounts array is behaving as an account is taking the form of an account,
22
00:01:48,480 --> 00:01:51,270
and the account class does not have a tax method.
23
00:01:53,880 --> 00:01:56,580
So here it's basically telling you, what are you talking about?
24
00:01:57,550 --> 00:02:04,270
But we can typecast the element at index zero to taxable because we know that checking account is taxable.
25
00:02:04,690 --> 00:02:07,210
And now we can tax an income of 4000.
26
00:02:08,050 --> 00:02:09,009
Don't tax.
27
00:02:10,800 --> 00:02:11,570
Four thousand.
28
00:02:12,800 --> 00:02:13,220
OK.
29
00:02:16,470 --> 00:02:17,820
Now we're going to make an assertion.
30
00:02:19,020 --> 00:02:24,180
After the taxes are deducted, the resulting balance should be five thousand three hundred and seventy
31
00:02:24,180 --> 00:02:25,800
four point five one.
32
00:02:26,790 --> 00:02:33,300
After we get the accounts, updated balance accounts and in zero, don't get balance.
33
00:02:36,000 --> 00:02:36,440
OK.
34
00:02:36,600 --> 00:02:37,560
Run the tests.
35
00:02:40,400 --> 00:02:43,670
And it fails now we can write code to make it pass.
36
00:02:47,380 --> 00:02:50,080
Inside of checking Java.
37
00:02:51,250 --> 00:02:54,820
I'm going to create a static final variable private static.
38
00:02:56,980 --> 00:02:58,510
Final double.
39
00:02:59,560 --> 00:03:00,670
Taxable income.
40
00:03:02,520 --> 00:03:03,990
Is equal to three thousand.
41
00:03:07,080 --> 00:03:11,730
And according to the requirements, the tax rate is 15 percent.
42
00:03:12,150 --> 00:03:15,630
So what I'm going to do is create another private static final.
43
00:03:20,190 --> 00:03:20,730
Double.
44
00:03:22,060 --> 00:03:25,750
Tax rate constant is equal to zero point one five.
45
00:03:26,710 --> 00:03:27,340
All right.
46
00:03:28,060 --> 00:03:29,530
And here what I'll do.
47
00:03:30,690 --> 00:03:32,790
Is it going to set double tax?
48
00:03:33,800 --> 00:03:35,690
Is equal to math a doubt, Max.
49
00:03:37,190 --> 00:03:45,200
Because either the amount that can be taxed is zero or it's the income minus the taxable income.
50
00:03:46,330 --> 00:03:50,440
The idea is that if the income is smaller than what's taxable, this is going to be negative.
51
00:03:50,440 --> 00:03:54,040
So Max returns zero, which means we don't want to tax them anything.
52
00:03:54,430 --> 00:03:59,350
Otherwise, if the income is bigger than what's taxable, then we're going to get some number that we
53
00:03:59,350 --> 00:04:01,180
can multiply by the tax rates.
54
00:04:02,590 --> 00:04:04,060
And that's going to be our tax.
55
00:04:08,630 --> 00:04:14,270
Now we can tax the person's account by saying super upset balance, and we'll update the balance by
56
00:04:14,270 --> 00:04:16,010
rounding whatever the result is.
57
00:04:18,560 --> 00:04:24,620
And that result is going to be based on us getting the current balance and deducting the tax.
58
00:04:26,660 --> 00:04:28,640
OK, if we rerun our test.
59
00:04:31,470 --> 00:04:32,370
Test Java.
60
00:04:35,820 --> 00:04:36,840
Everything works out.
61
00:04:37,260 --> 00:04:39,060
Let's rerun all of our tests.
62
00:04:43,990 --> 00:04:44,480
And we're good.
5399
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.