1
00:00:01,460 --> 00:00:03,350
In this video, we're going to finish up part two.

2
00:00:04,650 --> 00:00:11,010
Task five is to the dispense action, and we have this beautiful document to guide us public boolean

3
00:00:11,010 --> 00:00:11,880
dispense.

4
00:00:15,110 --> 00:00:18,590
Takes two parameters, entero and then spot.

5
00:00:22,560 --> 00:00:26,640
And first, we're going to check if the requested item has a bigger quantity than zero.

6
00:00:27,920 --> 00:00:29,030
So if the item.

7
00:00:34,630 --> 00:00:35,590
At the Rio.

8
00:00:37,990 --> 00:00:38,830
And spot.

9
00:00:45,880 --> 00:00:47,170
It's bigger than zero.

10
00:00:52,880 --> 00:00:57,830
We're going to dispense that item from the vending machine, so we need to decrease its quantity by

11
00:00:57,830 --> 00:00:58,190
one.

12
00:01:03,440 --> 00:01:04,400
Set quantity.

13
00:01:08,860 --> 00:01:11,650
We'll get the current quantity of what we're dispensing.

14
00:01:15,400 --> 00:01:16,450
And minus one.

15
00:01:20,560 --> 00:01:24,520
Then we need to return true to confirm that dispensing the drink was successful.

16
00:01:27,350 --> 00:01:32,210
Otherwise, if there isn't enough of that item to dispense, then we're going to return false.

17
00:01:36,010 --> 00:01:42,550
That's all Task six was to test the action, so inside me, I need to remove all code that comes after

18
00:01:42,550 --> 00:01:43,840
creating the machine object.

19
00:01:46,800 --> 00:01:52,080
I'm going to dispense a Pepsi bottle to the user twice, so I need to call the dispenser twice for the

20
00:01:52,080 --> 00:01:54,120
item at Rosero and spot zero.

21
00:01:57,770 --> 00:01:59,840
Machines that dispense zero zero.

22
00:02:10,889 --> 00:02:14,590
All right, and this should decrease the quantity of the Pepsi item by two.

23
00:02:14,790 --> 00:02:16,950
Let's make sure of that by printing the object.

24
00:02:22,290 --> 00:02:24,630
At Rosero and Spot Zero.

25
00:02:25,550 --> 00:02:26,600
And run your code.

26
00:02:38,430 --> 00:02:42,360
And after selling these are two Pepsis, there's only one left Perfect's.

27
00:02:43,830 --> 00:02:47,850
All right, let's clean up, we need to get ready for part three, so I'm going to remove all the code

28
00:02:47,850 --> 00:02:50,190
that follows creating the machine object.

29
00:02:51,000 --> 00:02:52,800
All right, I'll see you in part three.

