In this video, we're going to finish up part two.
Task five is to the dispense action, and we have this beautiful document to guide us public boolean
dispense.
Takes two parameters, entero and then spot.
And first, we're going to check if the requested item has a bigger quantity than zero.
So if the item.
At the Rio.
And spot.
It's bigger than zero.
We're going to dispense that item from the vending machine, so we need to decrease its quantity by
one.
Set quantity.
We'll get the current quantity of what we're dispensing.
And minus one.
Then we need to return true to confirm that dispensing the drink was successful.
Otherwise, if there isn't enough of that item to dispense, then we're going to return false.
That's all Task six was to test the action, so inside me, I need to remove all code that comes after
creating the machine object.
I'm going to dispense a Pepsi bottle to the user twice, so I need to call the dispenser twice for the
item at Rosero and spot zero.
Machines that dispense zero zero.
All right, and this should decrease the quantity of the Pepsi item by two.
Let's make sure of that by printing the object.
At Rosero and Spot Zero.
And run your code.
And after selling these are two Pepsis, there's only one left Perfect's.
All right, let's clean up, we need to get ready for part three, so I'm going to remove all the code
that follows creating the machine object.
All right, I'll see you in part three.