Added color to text output

Lose text is now red and winning text is now green
master
Victor Hans-Georg Waitz 2024-03-26 11:43:02 +01:00
parent 84862cf3ba
commit ed299fbf16
1 changed files with 6 additions and 3 deletions

View File

@ -1,6 +1,9 @@
import java.util.Scanner;
public class Main {
public static final String ANSI_RESET = "\u001B[0m";
public static final String RED = "\u001B[31m";
public static final String GREEN = "\u001B[32m";
static Scanner keyboard = new Scanner(System.in);
public static void main(String[] args) {
@ -20,12 +23,12 @@ public class Main {
// if (hand.isBlackJack()){
if (game.isHandBlackJack()){
nextRoundPrompt = "Glückwunsch, sie haben einen BlackJack und damit gewonnen!";
nextRoundPrompt = GREEN + "Glückwunsch, sie haben einen BlackJack und damit gewonnen!" + ANSI_RESET;
}
// if (hand.isOvershot()){
if (game.isHandOvershot()){
nextRoundPrompt = String.format("Leider verloren, der Wert der Hand ist mit %d höher als 21.", game.handValue());
nextRoundPrompt = String.format(RED + "Leider verloren, der Wert der Hand ist mit %d höher als 21." + ANSI_RESET, game.handValue());
}
if (nextRoundPrompt.isEmpty()) {
@ -49,7 +52,7 @@ public class Main {
boolean newRoundDecision = yesNoDecider(newRoundPrompt);
if (!(newRoundDecision)) {
System.out.println("Auf Wiedersehen :)");
System.out.println(RED + "Auf Wiedersehen :)" + ANSI_RESET);
break;
}
game = new BlackJackSpiel();