class Calculator { String xInput ="0"; char operator = ' '; boolean newCalc = true; public int yAkku; protected transient java.beans.PropertyChangeSupport propertyChange = new java.beans.PropertyChangeSupport(this); String fieldXInput = ""; public String appendInput (String label) { if ( newCalc ) { xInput = label; newCalc = false; } else { xInput = xInput + label; } return xInput; } public String clear () { xInput = "0"; yAkku = 0; operator = ' '; newCalc = true; return xInput; } public String function (String op) { int xReg = 0; try { xReg = Integer.parseInt (xInput); } catch (Exception e) {}; switch (operator) { case '+': yAkku = yAkku + xReg; break; case '-': yAkku = yAkku - xReg; break; case '*': yAkku = yAkku * xReg; break; case '/': yAkku = yAkku / xReg; break; default: yAkku = Integer.parseInt (xInput); } xInput = Integer.toString (yAkku); operator = op.charAt (0); newCalc = true; if ( op == "=" ) { yAkku = 0; } return xInput; } }