I have a high score list for a text based java game and I want my high score list to show the scores for the ten recent players. So technically its not a high score list, its just a list that shows the last ten player names who played the game and their scores.
My list works for the first ten players but after that it goes out of bounds and I dont know how to shift the elements in the list up by one. So if ten players have played and the score list is viewed, you will see their names and points, but after the 11th player plays and registers their score I want the list to remove the first player, and shift the others up by one then once the tenth element is blank it will register the 11th player's name and score.
I have included the snippet code for the scores as well as the whole code for my java project - (I tried uploading my project folder in a .zip file but the attachments keeps telling me "Error The server returned an error during upload") - so that anyone can understand my objective through the game and play my text based java game to understand what am I trying to do in case my objectives in this post are not clear.
Code for the method only is pasted below.
Full program code in notepad txt file - Program Code in text file
full program including the project folder in a zip file - Full program in project folder
Thank you and any help is appreciated.
Codes for the recent scores
My list works for the first ten players but after that it goes out of bounds and I dont know how to shift the elements in the list up by one. So if ten players have played and the score list is viewed, you will see their names and points, but after the 11th player plays and registers their score I want the list to remove the first player, and shift the others up by one then once the tenth element is blank it will register the 11th player's name and score.
I have included the snippet code for the scores as well as the whole code for my java project - (I tried uploading my project folder in a .zip file but the attachments keeps telling me "Error The server returned an error during upload") - so that anyone can understand my objective through the game and play my text based java game to understand what am I trying to do in case my objectives in this post are not clear.
Code for the method only is pasted below.
Full program code in notepad txt file - Program Code in text file
full program including the project folder in a zip file - Full program in project folder
Thank you and any help is appreciated.
Codes for the recent scores
public static void scoreChange(int prevScore[], int points) { for (int i3 = i2 + 1; i2 < i3; i3--){ prevScore[i2] = points; } } public static void nameChange(String prevScoreName[], String newName) { for (int i3 = i2 + 1; i2 < i3; i3--){ prevScoreName[i2] = newName; } } public static void printScores(int highScore[], String highScoreName[]) //a method that prints high scores { System.out.println("High Scores"); //FOR Loop to print High Scores for (int i3 = 0; i3 < TopScores.length; i3++){ System.out.println("Name: " + highScoreName[i3] + " " + "Points: " + highScore[i3]); } System.out.println(""); }