Guest User

Untitled

a guest
Jun 10th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. public class FoF{
  2. public static void main(String []args){
  3. Quiz3A a1 = new Quiz3A();
  4. a1.methodB(1,2);
  5. Quiz3A a2 = new Quiz3A(3);
  6. a2.methodB(2,4);
  7. a1.methodB(2,1);
  8. a2.methodB(1,3);
  9. }
  10. }
  11. public class Q5{
  12. private int sum;
  13. private int y;
  14. public int x;
  15. public Q5(){
  16. sum = 3;
  17. x = 1;
  18. y = 6;
  19. }
  20. public void methodA(){
  21. int x=1, y=1;
  22. msgClass [] msg = new msgClass[1];
  23. msgClass myMsg = new msgClass();
  24. myMsg.content = this.x;
  25. msg[0] = myMsg;
  26. msg[0].content = this.y + myMsg.content;
  27. this.y = this.y + methodB(msg[0]);
  28. y = methodB(msg[0]) + this.y;
  29. x = y + methodB(msg, msg[0]);
  30. sum = x + y + msg[0].content;
  31. System.out.println(x + " " + y+ " " + sum);
  32. }
  33. private int methodB(msgClass [] mg2, msgClass mg1){
  34. int x = 1;
  35. y = y + mg2[0].content;
  36. mg2[0].content = y + mg1.content;
  37. x = x + 3 + mg1.content;
  38. sum = sum + x + y;
  39. mg1.content = sum - mg2[0].content ;
  40. System.out.println(this.x + " " + this.y+ " " + sum);
  41. return sum;
  42. }
  43. private int methodB(msgClass mg1){
  44. int x = 1, y = 1;
  45. y = sum + mg1.content;
  46. this.y = y + mg1.content;
  47. x = this.x + 3 + mg1.content;
  48. sum = sum + x + y;
  49. this.x = mg1.content + x + 2;
  50. System.out.println(x + " " + y+ " " + sum);
  51. return y;
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment