Some Exception handling
parent
432ec54e1c
commit
38d1587405
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.
|
@ -260,33 +260,33 @@ public class Box {
|
|||
|
||||
public void selectOption(String option) {
|
||||
|
||||
if (option.equals("One"))
|
||||
if (option.equalsIgnoreCase("One"))
|
||||
setCategoryOne = categoryOne;
|
||||
else if (option.equals("Two"))
|
||||
else if (option.equalsIgnoreCase("Two"))
|
||||
setCategoryTwo = categoryTwo;
|
||||
else if (option.equals("Three"))
|
||||
else if (option.equalsIgnoreCase("Three"))
|
||||
setCategoryThree = categoryThree;
|
||||
else if (option.equals("Four"))
|
||||
else if (option.equalsIgnoreCase("Four"))
|
||||
setCategoryFour = categoryFour;
|
||||
else if (option.equals("Five"))
|
||||
else if (option.equalsIgnoreCase("Five"))
|
||||
setCategoryFive = categoryFive;
|
||||
else if (option.equals("Six"))
|
||||
else if (option.equalsIgnoreCase("Six"))
|
||||
setCategorySix = categorySix;
|
||||
else if (option.equals("Seven"))
|
||||
else if (option.equalsIgnoreCase("Seven"))
|
||||
setCategorySeven = categorySeven;
|
||||
else if (option.equals("Eight"))
|
||||
else if (option.equalsIgnoreCase("Eight"))
|
||||
setCategoryEight = categoryEight;
|
||||
else if (option.equals("TripleMatch"))
|
||||
else if (option.equalsIgnoreCase("TripleMatch"))
|
||||
setCategoryTripleMatch = categoryTripleMatch;
|
||||
else if (option.equals("FourOfAKind"))
|
||||
else if (option.equalsIgnoreCase("FourOfAKind"))
|
||||
setCategoryFourOfAKind = categoryFourOfAKind;
|
||||
else if (option.equals("FullHouse"))
|
||||
else if (option.equalsIgnoreCase("FullHouse"))
|
||||
setCategoryFullHouse = categoryFullHouse;
|
||||
else if (option.equals("SmallStreet"))
|
||||
else if (option.equalsIgnoreCase("SmallStreet"))
|
||||
setCategorySmallStreet = categorySmallStreet;
|
||||
else if (option.equals("BigStreet"))
|
||||
else if (option.equalsIgnoreCase("BigStreet"))
|
||||
setCategoryBigStreet = categoryBigStreet;
|
||||
else if (option.equals("Yahtzee")) {
|
||||
else if (option.equalsIgnoreCase("Yahtzee")) {
|
||||
if (setCategoryYahtzee != null) {
|
||||
setCategoryYahtzee += 50;
|
||||
if (counter[0] == 5)
|
||||
|
@ -308,13 +308,13 @@ public class Box {
|
|||
} else
|
||||
setCategoryYahtzee = categoryYahtzee;
|
||||
|
||||
} else if (option.equals("categoryChance"))
|
||||
} else if (option.equalsIgnoreCase("categoryChance"))
|
||||
setCategoryChance = categoryChance;
|
||||
else if (option.equals("Chance"))
|
||||
else if (option.equalsIgnoreCase("Chance"))
|
||||
setCategoryChance = categoryChance;
|
||||
else if (option.equals("StarWarsDay"))
|
||||
else if (option.equalsIgnoreCase("StarWarsDay"))
|
||||
setCategoryStarWarsDay = categoryStarWarsDay;
|
||||
else if (option.equals("R2D2"))
|
||||
else if (option.equalsIgnoreCase("R2D2"))
|
||||
setCategoryR2D2 = categoryR2D2;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package ui;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.Scanner;
|
||||
import facade.YahtzeeGame;
|
||||
|
@ -13,8 +14,9 @@ public class TUI {
|
|||
|
||||
System.out.println("\nYahtzee Star Wars Special!");
|
||||
|
||||
while (!choice.equals("Stop")) {
|
||||
while (!choice.equalsIgnoreCase("Stop")) {
|
||||
|
||||
try {
|
||||
YahtzeeGame game = new YahtzeeGame() {
|
||||
};
|
||||
System.out.println("\nMain menu:");
|
||||
|
@ -23,18 +25,22 @@ public class TUI {
|
|||
System.out.println(">Stop");
|
||||
choice = sc.nextLine();
|
||||
|
||||
if (choice.equals("Highscores")) {
|
||||
if (choice.equalsIgnoreCase("Highscores")) {
|
||||
try {
|
||||
System.out.println("\nChoose your gamemode:");
|
||||
System.out.println(">Normal");
|
||||
System.out.println(">Special8");
|
||||
System.out.println("\n" + game.showHighscores(sc.nextLine()));
|
||||
} catch (FileNotFoundException e) {
|
||||
System.out.println("\nHighscore file not found!\n");
|
||||
}
|
||||
System.out.println("\n>Return");
|
||||
System.out.println(">Delete");
|
||||
choice = sc.nextLine();
|
||||
if (choice.equals("Return")) {
|
||||
if (choice.equalsIgnoreCase("Return")) {
|
||||
}
|
||||
|
||||
else if (choice.equals("Delete")) {
|
||||
else if (choice.equalsIgnoreCase("Delete")) {
|
||||
System.out.println(
|
||||
"\nAre you sure you want to delete the Highscore file?\nAs a confirmation type: 'I AM SURE': ");
|
||||
choice = sc.nextLine();
|
||||
|
@ -49,15 +55,17 @@ public class TUI {
|
|||
|
||||
}
|
||||
|
||||
else if (choice.equals("Play")) {
|
||||
else if (choice.equalsIgnoreCase("Play")) {
|
||||
|
||||
System.out.println("\nChoose your gamemode: ");
|
||||
System.out.println(">Normal");
|
||||
System.out.println(">Special8");
|
||||
game.setGamemode(sc.nextLine());
|
||||
|
||||
System.out.println("\nAmount of players: ");
|
||||
System.out.println(">1-6");
|
||||
game.setPlayercount(Integer.parseInt(sc.nextLine()));
|
||||
|
||||
System.out.println("\nType in the player names, lock in each name with Enter: ");
|
||||
System.out.println(">ex. Lucas [Enter] William [Enter] Lena [Enter]");
|
||||
|
||||
|
@ -123,7 +131,8 @@ public class TUI {
|
|||
}
|
||||
if (game.gameOver(i)) {
|
||||
System.out.println(
|
||||
"\n\nYour game is over, here is your total score: " + game.returnTotalPoints(i));
|
||||
"\n\nYour game is over, here is your total score: "
|
||||
+ game.returnTotalPoints(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -135,6 +144,9 @@ public class TUI {
|
|||
"\nIf you want to stop the programm type: 'Stop', otherwise you will return to the main menu:");
|
||||
choice = sc.nextLine();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println("\nInput not accepted... Returning to the main menu...\n");
|
||||
}
|
||||
}
|
||||
sc.close();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue