Package oop13.space.controller

Source Code of oop13.space.controller.HighScoreController

package oop13.space.controller;

import oop13.space.model.HighScore;
import oop13.space.model.IModel;
import oop13.space.views.HighScoreGUI;
import oop13.space.views.HighScoreGUI.HighScoreObserver;
import oop13.space.views.HighScoreInterface;
import oop13.space.views.MainFrameInterface;

/**
* Controller handling the interaction with the
* {@link oop13.space.model.HighScore} and his view.
*
* @author Manuel Bottazzi
*/
public class HighScoreController implements HighScoreObserver {

  private MainFrameInterface mainFrame;
  private HighScoreInterface highScore;
  private IModel model;

  /**
     * Creates a new HighScoreController with the parameters provided in input.
   *
   * @param mainFrame - The {@link oop13.space.views.MainFrameInterface} to use for
   * changing the current panel displayed.
   *
   * @param model - The data used by the controller.
   */
  public HighScoreController(MainFrameInterface mainFrame, IModel model) {
    this.mainFrame = mainFrame;
    this.model = model;
  }

  /**
     * Sets the {@link oop13.space.views.HighScoreInterface} view the controller
   * has to observe.
   *
   * @param highScore - The {@link oop13.space.views.HighScoreInterface} to observe.
   */
  public void setView(HighScoreInterface highScore) {
    this.highScore = highScore;
    this.highScore.attachObserver(this);
  }

  @Override
  public void backCmd() {
    this.mainFrame.replacePanel(this.mainFrame.getMainMenu());
  }

  @Override
  public void resetCmd() {
    HighScore.getHighScore().resetHighScore();
    HighScoreGUI highScoreGUI = new HighScoreGUI();
    HighScoreController highScoreController = new HighScoreController(this.mainFrame, this.model);
    highScoreController.setView(highScoreGUI);
    this.mainFrame.replacePanel(highScoreGUI);
  }

}
TOP

Related Classes of oop13.space.controller.HighScoreController

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.