package eecs2030.lab5; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; /** * A controller that mediates the interaction between an RPSModel and an RPSView. * */ public class RPSController implements ActionListener { private RPSModel model; private RPSView view; /** * Returns the RPSModel used by this controller. * * @return the model */ public RPSModel getModel() { return this.model; } /** * Sets the RPSModel used by this controller. * * @param model the model to set */ public void setModel(RPSModel model) { this.model = model; } /** * Returns the RPSView used by this controller. * * @return the view */ public RPSView getView() { return this.view; } /** * Sets the RPSView used by this controller. * * @param view the view to set */ public void setView(RPSView view) { this.view = view; } /** * Processes an event initiated by a user clicking on a button in an RPSView. * * The ActionEvent object has-a string equal to one of * RPSUtils.ROCK, RPSUtils.PAPER, or RPSUtils.SCISSORS * indicating which hand the player has chosen. * * This method needs to orchestrate a series of method calls to the model * and view: * *
    *
  1. ask the model to play a hand using the player's chosen hand
  2. *
  3. ask the view to display the player's chosen hand
  4. *
  5. ask the view to display the computer's chosen hand
  6. *
  7. ask the model for the winner of the hand
  8. *
  9. ask the view to display the winner of the hand
  10. *
  11. ask the model for the number of games won, lost, and drawn by the player
  12. *
  13. ask the view to display the number of games won, lost, and drawn by the player
  14. *
* * @param e an action event object received from a button in the RPSView * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) */ @Override public void actionPerformed(ActionEvent e) { String player = e.getActionCommand(); // the hand played by the player } }