Has anybody ever used those machines at a gas station or grocery store where you get money for donating your recyclables? Well, I wanted to make a virtual one of those and so far everything's okay until I had to do some math. This is one of those things that make sense in your mind, but just won't work when you start turning it into code. I need the recyclable type's value times the amount and then added to the total money. But instead of adding it to the total money it seems to just change the total to the recent value I added. Let's say I add 2 cans, which is 10 cents, and then I add one more can after that, instead of having 15 cents total, I just have 5 cents. Hopefully you understand. I would also like some constructive criticism about my code. I know it's not the best, but I just started learning
java, so any help would be lovely.
I'll try my best to post an
SSCCE, but it will my first attempt.
Machine Class (Handles the GUI and ActionListener):
Not sure what to name this class, but it actually executes everything when the actionlistener is fired: