+ 2
Which is the best alternative solution?
3 ответов
+ 4
You could use an array, where the index of the button + 1 is the amount you increase myFrame.res by.
Something like:
myFrame.res += indexOf(myArray, myButtaction) + 1;
In the actionPerformed method.
Or, some sort of dictionary/struct class so each button has a number that would indicate how much you increase the value by.
+ 2
For what?
0
I want to add two numbers. When i push the button 1 and button 2 the
result would be 3 (1+2=3). The variable res (result) is out of public
void actionPerformed (ActionEvent e).
Which is the best way to write this code?