SpielKniffel Klasse fassade ändern

main
danai 2024-05-07 15:02:38 +02:00
parent b424564985
commit 5431c57491
1 changed files with 17 additions and 17 deletions

View File

@ -13,7 +13,7 @@ public class KniffelSpiel {
private Spiel spiel; private Spiel spiel;
private Scanner scanner; private Scanner scanner;
private Würfel würfel; //private Würfel würfel;
private int numPlayers; private int numPlayers;
public KniffelSpiel() { public KniffelSpiel() {
@ -32,6 +32,8 @@ public class KniffelSpiel {
} while (numSides != 6 && numSides != 8); } while (numSides != 6 && numSides != 8);
scanner.nextLine(); scanner.nextLine();
this.spiel = new Spiel(numPlayers, numSides); this.spiel = new Spiel(numPlayers, numSides);
//this.würfel = new Würfel(numSides);
} }
@ -54,12 +56,15 @@ public class KniffelSpiel {
for (Spieler player : spiel.getSpieler()) { for (Spieler player : spiel.getSpieler()) {
System.out.println("Player " + player.getNumber() + " of " + numPlayers + "'s turn:"); System.out.println("Player " + player.getNumber() + " of " + numPlayers + "'s turn:");
rollAndRerollDice(); rollAndRerollDice();
displayCategories(); displayCategories();
askUserForCategory(); askUserForCategory();
displayScore(); //displayScore();
} }
/*spiel.nextPlayer(); /*spiel.nextPlayer();
int currentPlayerIndex = spiel.getCurrentPlayerIndex(); int currentPlayerIndex = spiel.getCurrentPlayerIndex();
@ -78,7 +83,7 @@ public class KniffelSpiel {
break; break;
} }
} }
displayFinalScore(); //displayScore();
displayFinalScoreGewinner(); displayFinalScoreGewinner();
} }
@ -127,25 +132,27 @@ public class KniffelSpiel {
System.out.print("Enter category (1-17): "); System.out.print("Enter category (1-17): ");
int categoryIndex = scanner.nextInt(); int categoryIndex = scanner.nextInt();
scanner.nextLine(); // consume newline left-over scanner.nextLine();
//spiel.setKategorieScore(categoryIndex, calculateCategoryScore(categoryIndex)); //spiel.setKategorieScore(categoryIndex, calculateCategoryScore(categoryIndex));
int score = calculateCategoryScore(categoryIndex, würfel); int score = calculateCategoryScore(categoryIndex);
spiel.setKategorieScore(categoryIndex, score); spiel.setKategorieScore(categoryIndex, score);
int playerIndex = spiel.getCurrentPlayerIndex(); int playerIndex = spiel.getCurrentPlayerIndex();
spiel.getSpieler().get(playerIndex).setScoreForCategory(categoryIndex, score); spiel.getSpieler().get(playerIndex).setScoreForCategory(categoryIndex, score);
displayScore(categoryIndex);
} }
private int calculateCategoryScore(int categoryIndex, Würfel würfel) { private int calculateCategoryScore(int categoryIndex) {
return spiel.calculateKategorieScore(categoryIndex, würfel); return spiel.calculateKategorieScore(categoryIndex);
} }
private void displayScore() { private void displayScore(int categoryIndex) {
System.out.println("Score: " + spiel.calculateTotalScore(würfel)); System.out.println("Score: " + spiel.calculateTotalScore(categoryIndex));
} }
private boolean isGameFinished() { private boolean isGameFinished() {
@ -159,13 +166,7 @@ public class KniffelSpiel {
} }
private void displayFinalScore() {
System.out.println("Final score: " + spiel.calculateTotalScore(würfel));
}
public int[] getDiceValues() { public int[] getDiceValues() {
return spiel.getWürfelValues(); return spiel.getWürfelValues();
} }
@ -203,7 +204,6 @@ public class KniffelSpiel {
public void deleteHighscores() { public void deleteHighscores() {
spiel.getHighscores().clear(); spiel.getHighscores().clear();
System.out.println("Highscores have been deleted.");
} }