Class GameDetails

java.lang.Object
model.GameDetails
All Implemented Interfaces:
Serializable

public class GameDetails extends Object implements Serializable

The details for one game, including the user playing, the game settings the scoring (shots fired, ships destroyed, score and previous high score)

Company: TAFE SA

See Also:
  • Field Details

    • POINTS_GAINED_FOR_SHIP_DESTROYED

      public static final int POINTS_GAINED_FOR_SHIP_DESTROYED
      See Also:
    • POINTS_LOST_FOR_WASTED_SHOT

      public static final int POINTS_LOST_FOR_WASTED_SHOT
      See Also:
  • Constructor Details

    • GameDetails

      public GameDetails() throws Exception
      Throws:
      Exception
    • GameDetails

      public GameDetails(UserDetails user, GameSettings gameSettings) throws Exception
      Parameters:
      user - an instance of the UserDetails object
      gameSettings - an instance of the GameSettings object
      Throws:
      Exception
  • Method Details

    • setUserDetails

      public void setUserDetails(UserDetails userDetails)
      Parameters:
      userDetails - an instance of UserDetails
    • setGameSettings

      public void setGameSettings(GameSettings gameSettings)
      Parameters:
      gameSettings - an instance of GameSettings
    • getGameSettings

      public GameSettings getGameSettings()
      Returns:
      the gameSettings class
    • getUserDetails

      public UserDetails getUserDetails()
      Returns:
      the UserDetails class
    • setHighScore

      public void setHighScore(int score)
      Parameters:
      score - the value of the high score
    • getHighScore

      public int getHighScore()
      Returns:
      the value of the high score
    • setScore

      public void setScore(int score)
      Parameters:
      score - the score that you want to set
    • getScore

      public int getScore()
      Returns:
      the score of the user
    • setShipsDestroyed

      public void setShipsDestroyed(int ships)
      Parameters:
      ships - the number of ships that have been destroyed
    • getShipsDestroyed

      public int getShipsDestroyed()
      Returns:
      the number of ships that have been destroyed
    • setShotsFired

      public void setShotsFired(int shots)
      Parameters:
      shots - sets the number of shots that the user has fired
    • getShotsFired

      public int getShotsFired()
      Returns:
      the number of shots fired
    • isNewHighScore

      public boolean isNewHighScore()
      Returns:
      true or false if a score is a new high score
    • setNewHighScore

      public void setNewHighScore(boolean newHighScore)
      Parameters:
      newHighScore - if a new high score has been hit set to true otherwise false
    • toString

      public String toString()
      Overrides:
      toString in class Object
      Returns:
      all the values that GameDetails contains
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
      Parameters:
      obj -
      Returns:
    • calculateScoreChanges

      public int calculateScoreChanges()
      Returns:
      the current score
    • resetTheScoringDetails

      public final void resetTheScoringDetails() throws Exception
      Throws:
      Exception
    • saveData

      public void saveData() throws Exception
      Throws:
      Exception
    • loadData

      public void loadData() throws Exception
      Throws:
      Exception