Last fixes (Error Handling)
parent
24eafc0b0d
commit
7af2b8d295
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
bin/ui/TUI.class
BIN
bin/ui/TUI.class
Binary file not shown.
|
@ -13,19 +13,20 @@ import domain.Player;
|
|||
|
||||
public class YahtzeeGame {
|
||||
|
||||
public int playerCount;
|
||||
public ArrayList<Player> players = new ArrayList<>();
|
||||
public String savedGamemode;
|
||||
|
||||
public YahtzeeGame() {
|
||||
|
||||
}
|
||||
private int playerCount;
|
||||
private ArrayList<Player> 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++) {
|
||||
|
||||
|
|
|
@ -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,11 +32,19 @@ 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");
|
||||
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;
|
||||
|
|
Loading…
Reference in New Issue