natalierey

Untitled

Feb 20th, 2016
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.16 KB | None | 0 0
  1. package predictive;
  2.  
  3. import java.awt.event.ActionEvent;
  4. import java.awt.event.ActionListener;
  5.  
  6. public class Controller implements ActionListener
  7. {
  8. private Model model;
  9. private View view;
  10. private String currentSignature;
  11.  
  12. public Controller(Model model, View view)
  13. {
  14. this.model = model;
  15. this.view = view;
  16. view.getB0().addActionListener(this);
  17. view.getB1().addActionListener(this);
  18. view.getB2().addActionListener(this);
  19. view.getB3().addActionListener(this);
  20. view.getB4().addActionListener(this);
  21. view.getB5().addActionListener(this);
  22. view.getB6().addActionListener(this);
  23. view.getB7().addActionListener(this);
  24. view.getB8().addActionListener(this);
  25. view.getB9().addActionListener(this);
  26. view.getbAst().addActionListener(this);
  27. view.getbHash().addActionListener(this);
  28. }
  29.  
  30. @Override
  31. public void actionPerformed(ActionEvent e)
  32. {
  33. int i =0;
  34. if (e.getSource() == view.getB2())
  35. {
  36. currentSignature += "2";
  37. model.setCurrentSignature(currentSignature);
  38.  
  39. }
  40. else if (e.getSource() == view.getB3())
  41. {
  42. currentSignature += "3";
  43. model.setCurrentSignature(currentSignature);
  44. }
  45. else if (e.getSource() == view.getB4())
  46. {
  47. currentSignature += "4";
  48. model.setCurrentSignature(currentSignature);
  49. }
  50. else if (e.getSource() == view.getB5())
  51. {
  52. currentSignature += "5";
  53. model.setCurrentSignature(currentSignature);
  54. }
  55. else if (e.getSource() == view.getB6())
  56. {
  57. currentSignature += "6";
  58. model.setCurrentSignature(currentSignature);
  59. }
  60. else if (e.getSource() == view.getB7())
  61. {
  62. currentSignature += "7";
  63. model.setCurrentSignature(currentSignature);
  64. }
  65. else if (e.getSource() == view.getB8())
  66. {
  67. currentSignature += "8";
  68. model.setCurrentSignature(currentSignature);
  69. }
  70. else if (e.getSource() == view.getB9())
  71. {
  72. currentSignature += "9";
  73. model.setCurrentSignature(currentSignature);
  74. }
  75. else if (e.getSource() == view.getB0())
  76. {
  77. view.setCurrentMessage(view.getCurrentMessage() + " ");
  78. currentSignature = "";
  79. }
  80. else if (e.getSource() == view.getbHash())
  81. {
  82. model.setI(model.getI()+1);
  83. model.getNextWord();
  84. }
  85. }
  86. }
Add Comment
Please, Sign In to add comment