Guest User

Untitled

a guest
Jan 4th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. package beans;
  2.  
  3. public class CalculatorBean
  4. {
  5. int xvalue = 0;
  6. int yvalue = 0;
  7. int status = 1; // 1: success 0: error
  8. String errormessage = "";
  9.  
  10. public void setXvalue(String sx)
  11. {
  12. try
  13. {
  14. xvalue = Integer.parseInt(sx);
  15. }
  16. catch(Exception e)
  17. {
  18. status = 0;
  19. xvalue = 0;
  20. errormessage += "</br>Fill in a value in the upper field";
  21. }
  22. }
  23.  
  24. public int getXvalue()
  25. {
  26. return xvalue;
  27. }
  28.  
  29. public void setYvalue(String sy)
  30. {
  31. try
  32. {
  33. yvalue = Integer.parseInt(sy);
  34. }
  35. catch(Exception e)
  36. {
  37. status = 0;
  38. yvalue = 0;
  39. errormessage += "</br>Fill in a value in the lower field";
  40. }
  41. }
  42.  
  43. public int getYvalue()
  44. {
  45. return yvalue;
  46. }
  47.  
  48. public int getSum()
  49. {
  50. return xvalue + yvalue;
  51. }
  52.  
  53. public String getErrormessage() {
  54. return errormessage;
  55. }
  56.  
  57. public boolean isValid()
  58. {
  59. return status == 1;
  60. }
  61. }
Add Comment
Please, Sign In to add comment