Hi everyone, I have been instructed to build a vending machine, and I have seen some examples of vending machines and they have all a good amount of stuff in common but what I am looking for more specifically is how to create a method (in a different class) with a button or a JTextField as an argument. It would help me simplify my code so I dont have about 200 lines of code on the main page. The full code for it is attached below and there is the orignal vending machine and the class I intend to use for my calculations(*).
I'm not sure if this answers your question. In the interests of cleaning up code, I refactored a little.
Basically, this code does the same as Workout2, but in less than half the calls. One thing was to include a method to create a JButton, add it to the form's actionListener, and set the command. I then saw the huge amount of repetition in the actionListener and cleaned it but extending JButton to include so custom properties.