Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package beans;
- public class CalculatorBean
- {
- int xvalue = 0;
- int yvalue = 0;
- int status = 1; // 1: success 0: error
- String errormessage = "";
- public void setXvalue(String sx)
- {
- try
- {
- xvalue = Integer.parseInt(sx);
- }
- catch(Exception e)
- {
- status = 0;
- xvalue = 0;
- errormessage += "</br>Fill in a value in the upper field";
- }
- }
- public int getXvalue()
- {
- return xvalue;
- }
- public void setYvalue(String sy)
- {
- try
- {
- yvalue = Integer.parseInt(sy);
- }
- catch(Exception e)
- {
- status = 0;
- yvalue = 0;
- errormessage += "</br>Fill in a value in the lower field";
- }
- }
- public int getYvalue()
- {
- return yvalue;
- }
- public int getSum()
- {
- return xvalue + yvalue;
- }
- public String getErrormessage() {
- return errormessage;
- }
- public boolean isValid()
- {
- return status == 1;
- }
- }
Add Comment
Please, Sign In to add comment