Hey there.
So as you remember we have implemented both methods for our two buttons increased quantity and decreased
quantity.
And our buttons work as they should correctly increasing and decreasing the quantity by the minus button
can make their quantity negative.
This is not the behavior we need and we need to get rid of it somehow.
Let's go back to our main activity file.
Let's do the following in the decrease quantity method we will check whether quantity is a negative
number for these we will write the following.
If quantity less than zero
quantity assign zero
that is what we are doing here.
When the minus button is pressed we decrease the quantity variable by 1 and if for example the variable
quantity was 0 it becomes minus 1.
That is less than zero.
And in this case we reassign it to zero.
Let's restart our application.
Let's click on applause bottom now minus.
And as you can see when you click on the minus several times the zero is displayed.
Clicking on the plus button again increases by 1.
Cool.
We have achieved the desired behavior.
Well now we need to analyze their choice of goods.
But for these we need to get acquainted with data storage structures.