Scanner Printer fixes
parent
7af2b8d295
commit
4d068a6a5a
|
@ -7,4 +7,4 @@
|
||||||
___ ___ 0
|
___ ___ 0
|
||||||
___ ___ 0
|
___ ___ 0
|
||||||
___ ___ 0
|
___ ___ 0
|
||||||
___ ___ 0
|
___ ___ 0
|
|
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.
|
@ -7,4 +7,4 @@
|
||||||
___ ___ 0
|
___ ___ 0
|
||||||
___ ___ 0
|
___ ___ 0
|
||||||
___ ___ 0
|
___ ___ 0
|
||||||
___ ___ 0
|
___ ___ 0
|
|
|
@ -406,7 +406,7 @@ public class Box {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String selectedOptionsPrinted(int player) {
|
public String selectedOptionsPrinted() {
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
package domain;
|
package domain;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class Player {
|
public class Player {
|
||||||
|
|
||||||
public String name;
|
private String name;
|
||||||
public Hand hand;
|
private Hand hand;
|
||||||
public Box box;
|
private Box box;
|
||||||
public String savedGamemode;
|
private String savedGamemode;
|
||||||
|
|
||||||
public Player(String name, String gamemode) {
|
public Player(String name, String gamemode) {
|
||||||
|
|
||||||
|
@ -22,5 +24,103 @@ public class Player {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getPlayername(){
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void rollDices(){
|
||||||
|
this.hand.rollDices();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getLeftRolls(){
|
||||||
|
|
||||||
|
return hand.getLeftRolls();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<Integer> getAllDiceNumbers(){
|
||||||
|
|
||||||
|
return hand.getAllDiceNumbers();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<Integer> getFreeDiceNumbers(){
|
||||||
|
|
||||||
|
return hand.getFreeDiceNumbers();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<Integer> getLockedInDiceNumbers(){
|
||||||
|
|
||||||
|
return hand.getLockedInDiceNumbers();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getLockedInDiceAmount(){
|
||||||
|
return hand.getLockedInDiceAmount();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void lockInDices(String... dices){
|
||||||
|
|
||||||
|
hand.lockInDices(dices);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean autoLockInDices(){
|
||||||
|
|
||||||
|
return hand.autoLockInDices();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean allDicesLockedIn(){
|
||||||
|
return allDicesLockedIn();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void evaluateAllOptions(){
|
||||||
|
|
||||||
|
box.evaluateBoxOptions(hand.getLockedInDiceNumbers());
|
||||||
|
}
|
||||||
|
public ArrayList<String> getAllOptions(){
|
||||||
|
return box.getAllOptions();
|
||||||
|
}
|
||||||
|
public void selectOption(String selectedOption){
|
||||||
|
|
||||||
|
box.selectOption(selectedOption);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void resetOptions(){
|
||||||
|
box.resetOptions();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateBonus(){
|
||||||
|
box.updateBonus();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateUpperBoxScore(){
|
||||||
|
box.updateUpperBoxScore();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateLowerBoxScore(){
|
||||||
|
box.updateLowerBoxScore();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateTotalScore(){
|
||||||
|
box.updateTotalScore();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean onlyOneOption(){
|
||||||
|
|
||||||
|
return box.onlyOneOption();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String selectedOptionsPrinted(){
|
||||||
|
|
||||||
|
return box.selectedOptionsPrinted();
|
||||||
|
}
|
||||||
|
public boolean gameOver(){
|
||||||
|
|
||||||
|
return box.gameOver();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int returnTotalPoints(){
|
||||||
|
return box.returnTotalPoints();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ public class YahtzeeGame {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPlayerName(int player) {
|
public String getPlayerName(int player) {
|
||||||
return players.get(player).name;
|
return players.get(player).getPlayername();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGamemode(String gamemode) {
|
public void setGamemode(String gamemode) {
|
||||||
|
@ -47,56 +47,56 @@ public class YahtzeeGame {
|
||||||
|
|
||||||
public void rollDices(int player) {
|
public void rollDices(int player) {
|
||||||
|
|
||||||
players.get(player).hand.rollDices();
|
players.get(player).rollDices();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<Integer> getAllDiceNumbers(int player) {
|
public ArrayList<Integer> getAllDiceNumbers(int player) {
|
||||||
|
|
||||||
return players.get(player).hand.getAllDiceNumbers();
|
return players.get(player).getAllDiceNumbers();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<Integer> getFreeDiceNumbers(int player) {
|
public ArrayList<Integer> getFreeDiceNumbers(int player) {
|
||||||
|
|
||||||
return players.get(player).hand.getFreeDiceNumbers();
|
return players.get(player).getFreeDiceNumbers();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<Integer> getLockedInDiceNumbers(int player) {
|
public ArrayList<Integer> getLockedInDiceNumbers(int player) {
|
||||||
|
|
||||||
return players.get(player).hand.getLockedInDiceNumbers();
|
return players.get(player).getLockedInDiceNumbers();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getLockedInDiceAmount(int player) {
|
public int getLockedInDiceAmount(int player) {
|
||||||
|
|
||||||
return players.get(player).hand.getLockedInDiceAmount();
|
return players.get(player).getLockedInDiceAmount();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void lockInDices(int player, String... dices) {
|
public void lockInDices(int player, String... dices) {
|
||||||
|
|
||||||
if (dices[0].equalsIgnoreCase("none"))
|
if (dices[0].equalsIgnoreCase("none"))
|
||||||
return;
|
return;
|
||||||
players.get(player).hand.lockInDices(dices);
|
players.get(player).lockInDices(dices);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean autoLockInDices(int player) {
|
public boolean autoLockInDices(int player) {
|
||||||
|
|
||||||
return players.get(player).hand.autoLockInDices();
|
return players.get(player).autoLockInDices();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean allDicesLockedIn(int player) {
|
public boolean allDicesLockedIn(int player) {
|
||||||
|
|
||||||
return players.get(player).hand.getLockedInDiceAmount() == 5;
|
return players.get(player).getLockedInDiceAmount() == 5;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getLeftRolls(int player) {
|
public int getLeftRolls(int player) {
|
||||||
|
|
||||||
return players.get(player).hand.getLeftRolls();
|
return players.get(player).getLeftRolls();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,25 +108,25 @@ public class YahtzeeGame {
|
||||||
|
|
||||||
public void evaluateAllOptions(int player) {
|
public void evaluateAllOptions(int player) {
|
||||||
|
|
||||||
players.get(player).box.evaluateBoxOptions(players.get(player).hand.getLockedInDiceNumbers());
|
players.get(player).evaluateAllOptions();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<String> getAllOptions(int player) {
|
public ArrayList<String> getAllOptions(int player) {
|
||||||
|
|
||||||
return players.get(player).box.getAllOptions();
|
return players.get(player).getAllOptions();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void selectOption(int player, String selectedOption) {
|
public void selectOption(int player, String selectedOption) {
|
||||||
|
|
||||||
players.get(player).box.selectOption(selectedOption);
|
players.get(player).selectOption(selectedOption);
|
||||||
players.get(player).box.resetOptions();
|
players.get(player).resetOptions();
|
||||||
players.get(player).getNewHand();
|
players.get(player).getNewHand();
|
||||||
players.get(player).box.updateBonus();
|
players.get(player).updateBonus();
|
||||||
players.get(player).box.updateUpperBoxScore();
|
players.get(player).updateUpperBoxScore();
|
||||||
players.get(player).box.updateLowerBoxScore();
|
players.get(player).updateLowerBoxScore();
|
||||||
players.get(player).box.updateTotalScore();
|
players.get(player).updateTotalScore();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,18 +146,18 @@ public class YahtzeeGame {
|
||||||
|
|
||||||
public boolean onlyOneOption(int player) {
|
public boolean onlyOneOption(int player) {
|
||||||
|
|
||||||
return players.get(player).box.onlyOneOption();
|
return players.get(player).onlyOneOption();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String selectedOptionsPrinted(int player) {
|
public String selectedOptionsPrinted(int player) {
|
||||||
|
|
||||||
return players.get(player).box.selectedOptionsPrinted(player);
|
return players.get(player).selectedOptionsPrinted();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean gameOver(int player) {
|
public boolean gameOver(int player) {
|
||||||
|
|
||||||
return players.get(player).box.gameOver();
|
return players.get(player).gameOver();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,7 +165,7 @@ public class YahtzeeGame {
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
|
|
||||||
for (int i = 0; i < playerCount; i++) {
|
for (int i = 0; i < playerCount; i++) {
|
||||||
if (players.get(i).box.gameOver())
|
if (players.get(i).gameOver())
|
||||||
counter++;
|
counter++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,8 +174,8 @@ public class YahtzeeGame {
|
||||||
|
|
||||||
public int returnTotalPoints(int player) {
|
public int returnTotalPoints(int player) {
|
||||||
|
|
||||||
if (players.get(player).box.gameOver())
|
if (players.get(player).gameOver())
|
||||||
return players.get(player).box.returnTotalPoints();
|
return players.get(player).returnTotalPoints();
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -183,49 +183,35 @@ public class YahtzeeGame {
|
||||||
private String[][] refreshHighscoreList() throws FileNotFoundException {
|
private String[][] refreshHighscoreList() throws FileNotFoundException {
|
||||||
|
|
||||||
String highscores[][] = new String[10][3];
|
String highscores[][] = new String[10][3];
|
||||||
Scanner sc = new Scanner(new File("src/csv/highscores.csv"));
|
|
||||||
Scanner scSp = new Scanner(new File("src/csv/highscoresSpecial8.csv"));
|
|
||||||
String mem[] = new String[3];
|
String mem[] = new String[3];
|
||||||
|
String source;
|
||||||
if (savedGamemode.equalsIgnoreCase("Special8"))
|
|
||||||
|
if(savedGamemode.equalsIgnoreCase("Special8"))
|
||||||
for (int i = 0; i < 10; i++) {
|
source = "src/csv/highscoresSpecial8.csv";
|
||||||
|
|
||||||
if (scSp.hasNextLine()) {
|
|
||||||
|
|
||||||
mem = scSp.nextLine().split(" ");
|
|
||||||
highscores[i][0] = mem[0];
|
|
||||||
highscores[i][1] = mem[1];
|
|
||||||
highscores[i][2] = mem[2];
|
|
||||||
|
|
||||||
} else {
|
|
||||||
highscores[i][0] = "___";
|
|
||||||
highscores[i][1] = "___";
|
|
||||||
highscores[i][2] = "0";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
|
source = "src/csv/highscores.csv";
|
||||||
|
|
||||||
|
Scanner sc = new Scanner(new File(source));
|
||||||
|
|
||||||
for (int i = 0; i < 10; i++) {
|
|
||||||
|
|
||||||
if (sc.hasNextLine()) {
|
for (int i = 0; i < 10; i++) {
|
||||||
|
|
||||||
mem = sc.nextLine().split(" ");
|
if (sc.hasNextLine()) {
|
||||||
highscores[i][0] = mem[0];
|
|
||||||
highscores[i][1] = mem[1];
|
|
||||||
highscores[i][2] = mem[2];
|
|
||||||
|
|
||||||
} else {
|
mem = sc.nextLine().split(" ");
|
||||||
highscores[i][0] = "___";
|
highscores[i][0] = mem[0];
|
||||||
highscores[i][1] = "___";
|
highscores[i][1] = mem[1];
|
||||||
highscores[i][2] = "0";
|
highscores[i][2] = mem[2];
|
||||||
}
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
highscores[i][0] = "___";
|
||||||
|
highscores[i][1] = "___";
|
||||||
|
highscores[i][2] = "0";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
sc.close();
|
sc.close();
|
||||||
scSp.close();
|
|
||||||
return highscores;
|
return highscores;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -252,7 +238,7 @@ public class YahtzeeGame {
|
||||||
if (i == 2)
|
if (i == 2)
|
||||||
highscores[0][i] = "" + returnTotalPoints(player);
|
highscores[0][i] = "" + returnTotalPoints(player);
|
||||||
else if (i == 1)
|
else if (i == 1)
|
||||||
highscores[0][i] = "" + players.get(player).name;
|
highscores[0][i] = "" + players.get(player).getPlayername();
|
||||||
else if (i == 0)
|
else if (i == 0)
|
||||||
highscores[0][i] = "" + LocalDate.now();
|
highscores[0][i] = "" + LocalDate.now();
|
||||||
highscoreMem2 = highscores[1][i];
|
highscoreMem2 = highscores[1][i];
|
||||||
|
@ -281,7 +267,7 @@ public class YahtzeeGame {
|
||||||
if (i == 2)
|
if (i == 2)
|
||||||
highscores[1][i] = "" + returnTotalPoints(player);
|
highscores[1][i] = "" + returnTotalPoints(player);
|
||||||
else if (i == 1)
|
else if (i == 1)
|
||||||
highscores[1][i] = "" + players.get(player).name;
|
highscores[1][i] = "" + players.get(player).getPlayername();
|
||||||
else if (i == 0)
|
else if (i == 0)
|
||||||
highscores[1][i] = "" + LocalDate.now();
|
highscores[1][i] = "" + LocalDate.now();
|
||||||
highscoreMem1 = highscores[2][i];
|
highscoreMem1 = highscores[2][i];
|
||||||
|
@ -307,7 +293,7 @@ public class YahtzeeGame {
|
||||||
if (i == 2)
|
if (i == 2)
|
||||||
highscores[2][i] = "" + returnTotalPoints(player);
|
highscores[2][i] = "" + returnTotalPoints(player);
|
||||||
else if (i == 1)
|
else if (i == 1)
|
||||||
highscores[2][i] = "" + players.get(player).name;
|
highscores[2][i] = "" + players.get(player).getPlayername();
|
||||||
else if (i == 0)
|
else if (i == 0)
|
||||||
highscores[2][i] = "" + LocalDate.now();
|
highscores[2][i] = "" + LocalDate.now();
|
||||||
highscoreMem2 = highscores[3][i];
|
highscoreMem2 = highscores[3][i];
|
||||||
|
@ -331,7 +317,7 @@ public class YahtzeeGame {
|
||||||
if (i == 2)
|
if (i == 2)
|
||||||
highscores[3][i] = "" + returnTotalPoints(player);
|
highscores[3][i] = "" + returnTotalPoints(player);
|
||||||
else if (i == 1)
|
else if (i == 1)
|
||||||
highscores[3][i] = "" + players.get(player).name;
|
highscores[3][i] = "" + players.get(player).getPlayername();
|
||||||
else if (i == 0)
|
else if (i == 0)
|
||||||
highscores[3][i] = "" + LocalDate.now();
|
highscores[3][i] = "" + LocalDate.now();
|
||||||
highscoreMem1 = highscores[4][i];
|
highscoreMem1 = highscores[4][i];
|
||||||
|
@ -353,7 +339,7 @@ public class YahtzeeGame {
|
||||||
if (i == 2)
|
if (i == 2)
|
||||||
highscores[4][i] = "" + returnTotalPoints(player);
|
highscores[4][i] = "" + returnTotalPoints(player);
|
||||||
else if (i == 1)
|
else if (i == 1)
|
||||||
highscores[4][i] = "" + players.get(player).name;
|
highscores[4][i] = "" + players.get(player).getPlayername();
|
||||||
else if (i == 0)
|
else if (i == 0)
|
||||||
highscores[4][i] = "" + LocalDate.now();
|
highscores[4][i] = "" + LocalDate.now();
|
||||||
highscoreMem2 = highscores[5][i];
|
highscoreMem2 = highscores[5][i];
|
||||||
|
@ -373,7 +359,7 @@ public class YahtzeeGame {
|
||||||
if (i == 2)
|
if (i == 2)
|
||||||
highscores[5][i] = "" + returnTotalPoints(player);
|
highscores[5][i] = "" + returnTotalPoints(player);
|
||||||
else if (i == 1)
|
else if (i == 1)
|
||||||
highscores[5][i] = "" + players.get(player).name;
|
highscores[5][i] = "" + players.get(player).getPlayername();
|
||||||
else if (i == 0)
|
else if (i == 0)
|
||||||
highscores[5][i] = "" + LocalDate.now();
|
highscores[5][i] = "" + LocalDate.now();
|
||||||
highscoreMem1 = highscores[6][i];
|
highscoreMem1 = highscores[6][i];
|
||||||
|
@ -391,7 +377,7 @@ public class YahtzeeGame {
|
||||||
if (i == 2)
|
if (i == 2)
|
||||||
highscores[6][i] = "" + returnTotalPoints(player);
|
highscores[6][i] = "" + returnTotalPoints(player);
|
||||||
else if (i == 1)
|
else if (i == 1)
|
||||||
highscores[6][i] = "" + players.get(player).name;
|
highscores[6][i] = "" + players.get(player).getPlayername();
|
||||||
else if (i == 0)
|
else if (i == 0)
|
||||||
highscores[6][i] = "" + LocalDate.now();
|
highscores[6][i] = "" + LocalDate.now();
|
||||||
highscoreMem2 = highscores[7][i];
|
highscoreMem2 = highscores[7][i];
|
||||||
|
@ -407,7 +393,7 @@ public class YahtzeeGame {
|
||||||
if (i == 2)
|
if (i == 2)
|
||||||
highscores[7][i] = "" + returnTotalPoints(player);
|
highscores[7][i] = "" + returnTotalPoints(player);
|
||||||
else if (i == 1)
|
else if (i == 1)
|
||||||
highscores[7][i] = "" + players.get(player).name;
|
highscores[7][i] = "" + players.get(player).getPlayername();
|
||||||
else if (i == 0)
|
else if (i == 0)
|
||||||
highscores[7][i] = "" + LocalDate.now();
|
highscores[7][i] = "" + LocalDate.now();
|
||||||
highscoreMem1 = highscores[8][i];
|
highscoreMem1 = highscores[8][i];
|
||||||
|
@ -421,7 +407,7 @@ public class YahtzeeGame {
|
||||||
if (i == 2)
|
if (i == 2)
|
||||||
highscores[8][i] = "" + returnTotalPoints(player);
|
highscores[8][i] = "" + returnTotalPoints(player);
|
||||||
else if (i == 1)
|
else if (i == 1)
|
||||||
highscores[8][i] = "" + players.get(player).name;
|
highscores[8][i] = "" + players.get(player).getPlayername();
|
||||||
else if (i == 0)
|
else if (i == 0)
|
||||||
highscores[8][i] = "" + LocalDate.now();
|
highscores[8][i] = "" + LocalDate.now();
|
||||||
highscores[9][i] = highscoreMem1;
|
highscores[9][i] = highscoreMem1;
|
||||||
|
@ -432,34 +418,31 @@ public class YahtzeeGame {
|
||||||
if (i == 2)
|
if (i == 2)
|
||||||
highscores[9][i] = "" + returnTotalPoints(player);
|
highscores[9][i] = "" + returnTotalPoints(player);
|
||||||
else if (i == 1)
|
else if (i == 1)
|
||||||
highscores[9][i] = "" + players.get(player).name;
|
highscores[9][i] = "" + players.get(player).getPlayername();
|
||||||
else if (i == 0)
|
else if (i == 0)
|
||||||
highscores[9][i] = "" + LocalDate.now();
|
highscores[9][i] = "" + LocalDate.now();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PrintWriter out = new PrintWriter(new FileWriter("src/csv/highscores.csv", false));
|
String source;
|
||||||
PrintWriter outSp = new PrintWriter(new FileWriter("src/csv/highscoresSpecial8.csv", false));
|
|
||||||
|
if(savedGamemode.equalsIgnoreCase("Special8"))
|
||||||
if (savedGamemode.equalsIgnoreCase("Special8"))
|
source = "src/csv/highscoresSpecial8.csv";
|
||||||
for (int i = 0; i < 10; i++) {
|
|
||||||
|
|
||||||
outSp.print(highscores[i][0] + " " + highscores[i][1] + " "
|
|
||||||
+ highscores[i][2]);
|
|
||||||
|
|
||||||
outSp.println();
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
for (int i = 0; i < 10; i++) {
|
source = "src/csv/highscores.csv";
|
||||||
|
|
||||||
|
PrintWriter out = new PrintWriter(new FileWriter(source));
|
||||||
|
|
||||||
out.print(highscores[i][0] + " " + highscores[i][1] + " "
|
|
||||||
+ highscores[i][2]);
|
for (int i = 0; i < 10; i++) {
|
||||||
|
|
||||||
out.println();
|
out.print(highscores[i][0] + " " + highscores[i][1] + " "
|
||||||
}
|
+ highscores[i][2]);
|
||||||
|
|
||||||
|
out.println();
|
||||||
|
}
|
||||||
|
|
||||||
out.close();
|
out.close();
|
||||||
outSp.close();
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -492,16 +475,18 @@ public class YahtzeeGame {
|
||||||
|
|
||||||
public void deleteHighscores() throws IOException {
|
public void deleteHighscores() throws IOException {
|
||||||
|
|
||||||
PrintWriter out = new PrintWriter(new FileWriter("src/csv/highscores.csv", false));
|
String source;
|
||||||
PrintWriter outSp = new PrintWriter(new FileWriter("src/csv/highscoresSpecial8.csv", false));
|
|
||||||
|
if(savedGamemode.equalsIgnoreCase("Special8"))
|
||||||
if (savedGamemode.equalsIgnoreCase("Special8"))
|
source = "src/csv/highscoresSpecial8.csv";
|
||||||
outSp.print("");
|
|
||||||
else
|
else
|
||||||
out.print("");
|
source = "src/csv/highscores.csv";
|
||||||
|
|
||||||
|
PrintWriter out = new PrintWriter(new FileWriter(source));
|
||||||
|
|
||||||
|
out.print("");
|
||||||
|
|
||||||
out.close();
|
out.close();
|
||||||
outSp.close();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,12 +32,7 @@ public class TUI {
|
||||||
System.out.println("\nChoose your gamemode:");
|
System.out.println("\nChoose your gamemode:");
|
||||||
System.out.println(">Normal");
|
System.out.println(">Normal");
|
||||||
System.out.println(">Special8");
|
System.out.println(">Special8");
|
||||||
choice = sc.nextLine();
|
System.out.println("\n" + game.showHighscores(sc.nextLine()));
|
||||||
if(choice.equalsIgnoreCase("Special8"))
|
|
||||||
game.setGamemode("Special8");
|
|
||||||
else
|
|
||||||
game.setGamemode("Normal");
|
|
||||||
System.out.println("\n" + game.showHighscores(choice));
|
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
System.out.println("\nHighscore file not found!\n");
|
System.out.println("\nHighscore file not found!\n");
|
||||||
notFound = true;
|
notFound = true;
|
||||||
|
|
Loading…
Reference in New Issue