public class LeaderboardBackend
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private java.util.ArrayList<java.lang.String[]> |
ArrayOfPeopleWithScores |
Constructor and Description |
---|
LeaderboardBackend() |
Modifier and Type | Method and Description |
---|---|
static void |
AddPlayerToLeaderboard(java.lang.String player,
int score)
This method handles adding new players to the end of the Game save file
|
java.util.ArrayList<java.lang.String[]> |
getListofScores()
Returns the array list of the leaderboard scores
|
java.lang.String[][] |
GetTopThree()
A function that that returns the players names and the scores that have the top three highest scores.
|
void |
OpenFile()
This method opens the GameSave.txt file, splits the vaules held in the file
and the populates the array list "arrayofpeoplewithscores".
|
private int |
ReturnBestPlayer(java.util.ArrayList<java.lang.String[]> a)
This function will return the best three players that have played the game so that they are able to be displayed
|
private java.util.ArrayList<java.lang.String[]> ArrayOfPeopleWithScores
public java.util.ArrayList<java.lang.String[]> getListofScores()
public static void AddPlayerToLeaderboard(java.lang.String player, int score)
player
- - This is the name of the player that you want to store(type String)score
- - the score of the player that you want to store (type int)public void OpenFile()
This method also contains error handling for if the file "GameSave.txt" does not exist. If the file does not exist, the method will create the file and populate it with Example players.
private int ReturnBestPlayer(java.util.ArrayList<java.lang.String[]> a)
This method also contains error handling for if the "GameSave.txt" file contains less than three players
public java.lang.String[][] GetTopThree()