From eb361a6f58214840b31a3240d4ef92fc7e1126a3 Mon Sep 17 00:00:00 2001 From: "s.eser" Date: Sun, 28 Apr 2024 19:05:07 +0200 Subject: [PATCH] highscore functions done --- bin/domain/Box.class | Bin 8667 -> 8667 bytes bin/domain/Dice.class | Bin 1036 -> 1036 bytes bin/domain/Hand.class | Bin 2512 -> 2512 bytes bin/domain/Player.class | Bin 705 -> 705 bytes bin/facade/YahtzeeGame.class | Bin 7829 -> 8501 bytes bin/ui/TUI.class | Bin 240 -> 240 bytes src/facade/YahtzeeGame.java | 48 ++++++++++++++++++++++++++--------- 7 files changed, 36 insertions(+), 12 deletions(-) diff --git a/bin/domain/Box.class b/bin/domain/Box.class index 8ebf2b505eaa9a373e991646f5151c0e273770cc..a173d93f2e8071d43dd428fc945e3d6122f24f72 100644 GIT binary patch delta 17 ZcmccZeA}7h)W2Q(7#J8FH*#E71OQ9#2Xg=b delta 17 ZcmccZeA}7h)W2Q(7#J9AH*#E71OQ9h2X6oX diff --git a/bin/domain/Dice.class b/bin/domain/Dice.class index 4a4ca3c5738aa7af0ef8cb5edd118ae32230cf3b..abcd61ad2e4fa84f8c004acd792fbd99ef503c76 100644 GIT binary patch delta 17 YcmeC-=;7cv^>5cc1_lPljT|g206A&}a{vGU delta 17 YcmeC-=;7cv^>5cc1_lP(jT|g206A6#ZvX%Q diff --git a/bin/domain/Hand.class b/bin/domain/Hand.class index 0ec25ba979212e31ac8f992cc08aae39697ae600..3e90cd41ba4cbfd8e0fcfc1b2f343424d4e8d214 100644 GIT binary patch delta 17 Zcmca0d_kDw)W2Q(7#J8FH*%cd1OP2G#%o diff --git a/bin/domain/Player.class b/bin/domain/Player.class index e97c8034e7633a7df7a7201685418f157a34f967..dc8b686b87f79694c69b1fb7ad659e3949d6b96b 100644 GIT binary patch delta 17 ZcmX@edXSal)W2Q(7#J8FH*)M`0sui628sXx delta 17 ZcmX@edXSal)W2Q(7#J9AH*)M`0suh-28I9t diff --git a/bin/facade/YahtzeeGame.class b/b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~;=9(TaeWx8E$|G+y4r56_wFc9<(YQ!nYS6t#x1f(F z#hO8tFa}006T-wx;v@RU-^9uOzhmoBm^_%ogH7&0a@J>Z8Z$Zd1DrXMEE1Ea6qUK; zlqp5y24=l3Sv;jkISNYT0uzVGye^JEioAZhRyu}U&rUZ~)A_&q&;NLM$1qR+Fp V{vZCnjduwFU#tBE@8NGK{!eI%?A`zX diff --git a/bin/ui/TUI.class b/bin/ui/TUI.class index 3727185a5d183bb0976aa03e5dc61ee0e2338758..eb2cafb22a9cb71c15edf0e64d71de6b4faa3b6f 100644 GIT binary patch delta 16 Ycmeys_<@n*)W2Q(7#J8FCvv<106%XA?EnA( delta 16 Ycmeys_<@n*)W2Q(7#J9ACvv<106$*_=>Px# 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