diff --git a/bin/domain/Box.class b/bin/domain/Box.class index 56c84e3..6cdd89b 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 596a7ed..e07cc5a 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 986e04a..e8f03e9 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 7a11635..85e7b0e 100644 Binary files a/bin/facade/YahtzeeGame.class and b/bin/facade/YahtzeeGame.class differ diff --git a/bin/ui/TUI$1.class b/bin/ui/TUI$1.class index 33b5c28..ea68ac5 100644 Binary files a/bin/ui/TUI$1.class and b/bin/ui/TUI$1.class differ diff --git a/bin/ui/TUI.class b/bin/ui/TUI.class index 2043ee4..cf65bfd 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 8049a42..9bc4714 100644 --- a/src/facade/YahtzeeGame.java +++ b/src/facade/YahtzeeGame.java @@ -13,19 +13,20 @@ import domain.Player; public class YahtzeeGame { - public int playerCount; - public ArrayList players = new ArrayList<>(); - public String savedGamemode; - - public YahtzeeGame() { - - } + private int playerCount; + private ArrayList players = new ArrayList<>(); + private String savedGamemode; public void setPlayercount(int playerCount) { this.playerCount = playerCount; } + public int getPlayercount(){ + return this.playerCount; + + } + public void setPlayerNames(String... names) { for (int i = 0; i < this.playerCount; i++) { diff --git a/src/ui/TUI.java b/src/ui/TUI.java index ecddf82..797ebfa 100644 --- a/src/ui/TUI.java +++ b/src/ui/TUI.java @@ -10,6 +10,7 @@ public class TUI { public static void main(String[] args) throws IOException { String choice = ""; + boolean notFound = false; Scanner sc = new Scanner(System.in); System.out.println("\nYahtzee Star Wars Special!"); @@ -19,6 +20,7 @@ public class TUI { try { YahtzeeGame game = new YahtzeeGame() { }; + notFound = false; System.out.println("\nMain menu:"); System.out.println(">Play"); System.out.println(">Highscores"); @@ -30,12 +32,20 @@ public class TUI { System.out.println("\nChoose your gamemode:"); System.out.println(">Normal"); System.out.println(">Special8"); - System.out.println("\n" + game.showHighscores(sc.nextLine())); + choice = sc.nextLine(); + if(choice.equalsIgnoreCase("Special8")) + game.setGamemode("Special8"); + else + game.setGamemode("Normal"); + System.out.println("\n" + game.showHighscores(choice)); } catch (FileNotFoundException e) { System.out.println("\nHighscore file not found!\n"); + notFound = true; } + System.out.println("\n>Return"); - System.out.println(">Delete"); + if(!notFound) + System.out.println(">Delete"); choice = sc.nextLine(); if (choice.equalsIgnoreCase("Return")) { } @@ -69,9 +79,9 @@ public class TUI { System.out.println("\nType in the player names, lock in each name with Enter: "); System.out.println(">ex. Lucas [Enter] William [Enter] Lena [Enter]"); - String playerNames[] = new String[game.playerCount]; + String playerNames[] = new String[game.getPlayercount()]; - for (int i = 0; i < game.playerCount; i++) { + for (int i = 0; i < game.getPlayercount(); i++) { playerNames[i] = sc.nextLine(); } @@ -79,7 +89,7 @@ public class TUI { while (!game.gameOverAll()) { - for (int i = 0; i < game.playerCount; i++) { + for (int i = 0; i < game.getPlayercount(); i++) { if (game.gameOver(i)) continue;