Package model

Class HighscoreDb

java.lang.Object
model.HighscoreDb

public class HighscoreDb
extends java.lang.Object
HighscoreDb has methods to communicate with the database holding highscores and corresponding names.
  • Constructor Summary

    Constructors 
    Constructor Description
    HighscoreDb​(java.lang.String DB_TABLE)  
    HighscoreDb​(java.lang.String DB_URL, java.lang.String DB_TABLE, java.lang.String USER, java.lang.String PASS)  
  • Method Summary

    Modifier and Type Method Description
    boolean close()
    close() - Closes the connection with the highscore database.
    boolean connect()
    connect() - Establishes a connection with the highscore database.
    java.util.ArrayList<Highscore> getHighscores()
    getHighscores() - Retracts a list of highscores from database.
    boolean insertScore​(Highscore h)
    insertScore() - Inserts highscore into database.
    boolean setUp()
    setUp() - For testing.
    boolean tearDown()
    tearDown() - For testing.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • HighscoreDb

      public HighscoreDb​(java.lang.String DB_URL, java.lang.String DB_TABLE, java.lang.String USER, java.lang.String PASS)
    • HighscoreDb

      public HighscoreDb​(java.lang.String DB_TABLE)
  • Method Details

    • connect

      public boolean connect()
      connect() - Establishes a connection with the highscore database.
      Returns:
      - True if the connection was successful. False otherwise.
    • setUp

      public boolean setUp()
      setUp() - For testing.
      Returns:
      True if set up of database was successful. False otherwise.
    • tearDown

      public boolean tearDown()
      tearDown() - For testing.
      Returns:
      True if tearDown of database was successful. False otherwise.
    • close

      public boolean close()
      close() - Closes the connection with the highscore database.
      Returns:
      - True if closing the connection succeeded. False otherwise.
    • insertScore

      public boolean insertScore​(Highscore h)
      insertScore() - Inserts highscore into database.
      Parameters:
      h - - Highscore to be inserted.
      Returns:
      - True if insert was successful. False otherwise.
    • getHighscores

      public java.util.ArrayList<Highscore> getHighscores()
      getHighscores() - Retracts a list of highscores from database.
      Returns:
      - ArrayList containing highscores.