Inventory/Storing

I need help making code so I can collect gas, and then when I go to a gasoline generator, it takes the gas out of my inventory and processes it as a function

Btw I main Java

I have an idea!
Make a variable of gas collected! So when you collect 1 gas you change the GasCollected variable by 1 (or make it so it is more) Then when you get to a generator you set the GasInGenerator to GasCollected and then set GasCollected to 0!
Hope this helps!

I had that idea too! Instead of ‘GasCollected’ I had ‘AddGas’. But how do I change a variable value?

AddGas += 1