diff --git a/bin/domain/Box.class b/bin/domain/Box.class index 8ebf2b5..a173d93 100644 Binary files a/bin/domain/Box.class and b/bin/domain/Box.class differ diff --git a/bin/domain/Dice.class b/bin/domain/Dice.class index 4a4ca3c..abcd61a 100644 Binary files a/bin/domain/Dice.class and b/bin/domain/Dice.class differ diff --git a/bin/domain/Hand.class b/bin/domain/Hand.class index 0ec25ba..3e90cd4 100644 Binary files a/bin/domain/Hand.class and b/bin/domain/Hand.class differ diff --git a/bin/domain/Player.class b/bin/domain/Player.class index e97c803..dc8b686 100644 Binary files a/bin/domain/Player.class and b/bin/domain/Player.class differ diff --git a/bin/facade/YahtzeeGame.class b/bin/facade/YahtzeeGame.class index 0563abc..4099096 100644 Binary files a/bin/facade/YahtzeeGame.class and b/bin/facade/YahtzeeGame.class differ diff --git a/bin/ui/TUI.class b/bin/ui/TUI.class index 3727185..eb2cafb 100644 Binary files a/bin/ui/TUI.class and b/bin/ui/TUI.class differ diff --git a/src/facade/YahtzeeGame.java b/src/facade/YahtzeeGame.java index ee40a43..ee20936 100644 --- a/src/facade/YahtzeeGame.java +++ b/src/facade/YahtzeeGame.java @@ -1,7 +1,6 @@ package facade; import java.io.FileNotFoundException; -import java.io.FileWriter; import java.io.PrintWriter; import java.time.LocalDate; import java.util.ArrayList; @@ -14,13 +13,14 @@ public class YahtzeeGame { public int playerCount; public ArrayList players = new ArrayList<>(); public String savedGamemode; - public String gameSheet; + public YahtzeeGame(int playerCount, String gamemode, String... names) { this.playerCount = playerCount; this.savedGamemode = gamemode; + for (int i = 0; i < this.playerCount; i++) { this.players.add(new Player(names[i], this.savedGamemode)); @@ -93,11 +93,9 @@ public class YahtzeeGame { return 0; } - public void setScoreToHighscores(int player) throws FileNotFoundException { + private String[][] refreshHighscoreList(){ String highscores[][] = new String[10][3]; - String highscoreMem1 = ""; - String highscoreMem2 = ""; Scanner sc = new Scanner("src/csv/highscores.csv"); for (int i = 0; i < 10; i++) { @@ -109,18 +107,19 @@ public class YahtzeeGame { } } - for (int i = 0; i < 10; i++) { + sc.close(); + return highscores; + } + + public void setScoreToHighscores(int player, String highscores[][]) throws FileNotFoundException { - if (highscores[i][2] == null) { - highscores[i][0] = sc.next(); - highscores[i][1] = sc.next(); - highscores[i][2] = sc.nextLine(); - } - } + String highscoreMem1 = ""; + String highscoreMem2 = ""; try { if (returnTotalPoints(player) < Integer.parseInt(highscores[9][2])) { + return; } @@ -335,5 +334,30 @@ public class YahtzeeGame { out.close(); } catch (Exception e) { } + + } + + public void saveAllPlayersHighscores() throws FileNotFoundException{ + + for(int i = 0; i