Nearly everything implemented
parent
0dc39592db
commit
df415b4042
|
@ -0,0 +1 @@
|
|||
|
|
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.
|
@ -0,0 +1 @@
|
|||
|
|
|
@ -42,8 +42,10 @@ public class Hand {
|
|||
|
||||
public int getLockedInDiceAmount() {
|
||||
|
||||
if (lockedInDices != null)
|
||||
return lockedInDices.size();
|
||||
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void rollDices() {
|
||||
|
@ -89,7 +91,7 @@ public class Hand {
|
|||
public ArrayList<Integer> getLockedInDiceNumbers() {
|
||||
ArrayList<Integer> res = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < this.lockedInDices.size(); i++) {
|
||||
for (int i = 0; i < getLockedInDiceAmount(); i++) {
|
||||
|
||||
res.add(this.lockedInDices.get(i).getDiceNumber());
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package facade;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
|
@ -151,10 +153,10 @@ public class YahtzeeGame {
|
|||
return 0;
|
||||
}
|
||||
|
||||
private String[][] refreshHighscoreList() {
|
||||
private String[][] refreshHighscoreList() throws FileNotFoundException {
|
||||
|
||||
String highscores[][] = new String[10][3];
|
||||
Scanner sc = new Scanner("src/csv/highscores.csv");
|
||||
Scanner sc = new Scanner(new File("src/csv/highscores.csv"));
|
||||
|
||||
for (int i = 0; i < 10; i++) {
|
||||
|
||||
|
@ -162,7 +164,12 @@ public class YahtzeeGame {
|
|||
highscores[i][0] = sc.next();
|
||||
highscores[i][1] = sc.next();
|
||||
highscores[i][2] = sc.nextLine();
|
||||
} else {
|
||||
highscores[i][0] = "___";
|
||||
highscores[i][1] = "___";
|
||||
highscores[i][2] = "0";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
sc.close();
|
||||
|
@ -402,7 +409,7 @@ public class YahtzeeGame {
|
|||
|
||||
}
|
||||
|
||||
public String showHighscores() {
|
||||
public String showHighscores() throws FileNotFoundException {
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
package ui;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Scanner;
|
||||
|
||||
import facade.YahtzeeGame;
|
||||
|
||||
public class TUI {
|
||||
|
@ -12,16 +10,13 @@ public class TUI {
|
|||
|
||||
String choice = "";
|
||||
Scanner sc = new Scanner(System.in);
|
||||
boolean newGame = false;
|
||||
|
||||
System.out.println("Yahtzee Star Wars Special!");
|
||||
|
||||
while (newGame) {
|
||||
YahtzeeGame game = new YahtzeeGame() {
|
||||
};
|
||||
|
||||
while (!choice.equals("stop")) {
|
||||
|
||||
YahtzeeGame game = new YahtzeeGame() {
|
||||
};
|
||||
System.out.println("Main menu:\n");
|
||||
System.out.println(">Play");
|
||||
System.out.println(">Highscores");
|
||||
|
@ -32,8 +27,9 @@ public class TUI {
|
|||
System.out.println(">Return");
|
||||
System.out.println(">Delete");
|
||||
choice = sc.nextLine();
|
||||
if (choice.equals("Return"))
|
||||
break;
|
||||
if (choice.equals("Return")) {
|
||||
}
|
||||
|
||||
else if (choice.equals("Delete")) {
|
||||
System.out.println(
|
||||
"Are you sure you want to delete the Highscore file?\nAs a confirmation type: 'I AM SURE': ");
|
||||
|
@ -107,12 +103,13 @@ public class TUI {
|
|||
}
|
||||
}
|
||||
|
||||
System.out.println("The game is over, saving all highscores to the highscore table...");
|
||||
System.out.println("The game is over, " + game.getWinnerMessage());
|
||||
System.out.println("Saving all highscores to the highscore table...");
|
||||
game.saveAllPlayersHighscores();
|
||||
|
||||
System.out.println(
|
||||
"If you want to stop the programm type: 'stop', otherwise you will return to the main menu:");
|
||||
choice = sc.nextLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue