"public class GameModule {
    private static final int NUM_ROUNDS = 4;

    public static void main(String[] args) {
        Keyboard keyboard = new Keyboard();

        System.out.println("HighSum GAME");
        System.out.println("================================================================================");

        String playerName = Keyboard.readString("Enter Login name > ");
        String playerPassword = Keyboard.readString("Enter Password > ");

        Player player = new Player(playerName, playerPassword, 100);
        Dealer dealer = new Dealer();
        Deck deck = new Deck();

        boolean nextGame = true;
        while (nextGame) {
            System.out.println("================================================================================");
            System.out.println(playerName + ", You have " + player.getChips() + " chips");
            System.out.println("--------------------------------------------------------------------------------");
            System.out.println("Game starts - Dealer shuffles deck.");
            System.out.println("--------------------------------------------------------------------------------");
            System.out.println("Dealer dealing cards - ROUND 1");
            System.out.println("--------------------------------------------------------------------------------");

            deck.shuffle();
            dealer.clearCardsOnHand();
            player.clearCardsOnHand();

            // Switch the order of dealer and player to deal cards to the dealer first
            for (int i = 0; i < 2; i++) {
                dealer.addCard(deck.dealCard());
                player.addCard(deck.dealCard());
            }

            int betOnTable = 0;

            for (int round = 1; round <= NUM_ROUNDS; round++) {
                System.out.println("--------------------------------------------------------------------------------");
                System.out.println("Dealer dealing cards - ROUND " + round);
                System.out.println("--------------------------------------------------------------------------------");

                // Show dealer’s cards first, then player’s cards
                dealer.showCardsOnHand();
                player.showCardsOnHand();
                System.out.println("Value: " + player.getTotalCardsValue());

                if (round > 1) {
                    dealer.addCard(deck.dealCard());
                    player.addCard(deck.dealCard());
                }

                if (round == 4) {
                    dealer.revealHiddenCard();
                }

                    if (player.getTotalCardsValue() > dealer.getTotalCardsValue()) {
                        System.out.println(playerName + " Wins");
                        player.addChips(betOnTable);
                    } else {
                        System.out.println("Dealer Wins");
                    }
                }
            }

            boolean valid = false;
            while (!valid) {
                String input = Keyboard.readString("Next Game? (Y/N) > ").toLowerCase();
                if (input.equals("y")) {
                    nextGame = true;
                    valid = true;
                } else if (input.equals("n")) {
                    nextGame = false;
                    valid = true;
                } else {
                    System.out.println("*** Please enter Y or N ***");
                }
            }
        }
    }

import java.util.ArrayList;
import java.util.Random;

public class Deck {
    private ArrayList<Card> cards;

    public Deck() {
        cards = new ArrayList<Card>();
        String[] suits = {"Heart", "Diamond", "Spade", "Club"};
        for (int i = 0; i < suits.length; i++) {
            String suit = suits[i];
            Card card = new Card(suit, "Ace", 1);
            cards.add(card);
            for (int n = 2; n <= 10; n++) {
                Card aCard = new Card(suit, n + "", n);
                cards.add(aCard);
            }
            Card jackCard = new Card(suit, "Jack", 10);
            cards.add(jackCard);
            Card queenCard = new Card(suit, "Queen", 10);
            cards.add(queenCard);
            Card kingCard = new Card(suit, "King", 10);
            cards.add(kingCard);
        }
    }

    public void shuffle() {
        Random random = new Random();
        for (int i = 0; i < 1000; i++) {
            int indexA = random.nextInt(cards.size());
            int indexB = random.nextInt(cards.size());
            Card cardA = cards.get(indexA);
            Card cardB = cards.get(indexB);
            cards.set(indexA, cardB);
            cards.set(indexB, cardA);
        }
    }

    public Card dealCard() {
        return cards.remove(0);
    }
}
public class Dealer extends Player {
    public Dealer() {
        super("Dealer", "", 0);
    }

    @Override
    public void addCard(Card card) {
        super.addCard(card);
        
        // Hide only the first card for the dealer
        if (cardsOnHand.size() == 1) {
            cardsOnHand.get(0).hide();
        }
    }

    @Override
    public void showCardsOnHand() {
        System.out.println(getLoginName());
        int numCards = cardsOnHand.size();
        for (int i = 0; i < numCards; i++) {
            System.out.print(cardsOnHand.get(i));
            if (i < numCards - 1) {
                System.out.print(", ");
            }
        }
        System.out.println("\n");
    }
    
    public void revealHiddenCard() {
        if (!cardsOnHand.isEmpty()) {
            cardsOnHand.get(0).reveal();
        }
    }
}

public class Card {
    private String suit;
    private String name;
    private int value;
    private boolean hidden;

    public Card(String suit, String name, int value) {
        this.suit = suit;
        this.name = name;
        this.value = value;
        this.hidden = false; // Change this line to make cards revealed by default
    }

    public int getValue() {
        return value;
    }

    public void reveal() {
        this.hidden = false;
    }

    public boolean isHidden() {
        return hidden;
    }

    @Override
    public String toString() {
        return this.hidden ? "<HIDDEN CARD>" : "<" + this.suit + " " + this.name + ">";
    }

    public static void main(String[] args) {
        Card card = new Card("Heart", "Ace", 1);
        System.out.println(card);
    }
    
    public void hide() {
        this.hidden = true;
    }
}
public class User {
    private String loginName;
    private String password;

    public User(String loginName, String password) {
        this.loginName = loginName;
        this.password = password;
    }

    public String getLoginName() {
        return loginName;
    }

    public boolean checkPassword(String password) {
        return this.password.equals(password);
    }
}
import java.util.ArrayList;

public class Player extends User {
    private int chips;
    protected ArrayList<Card> cardsOnHand;

    public Player(String loginName, String password, int chips) {
        super(loginName, password);
        this.chips = chips;
        this.cardsOnHand = new ArrayList<Card>();
    }

    public void addCard(Card card) {
        this.cardsOnHand.add(card);
    }

    public void showCardsOnHand() {
        System.out.println(getLoginName());
        int numCards = cardsOnHand.size();
        for (int i = 0; i < numCards; i++) {
            if (i < numCards - 1) {
                System.out.print(cardsOnHand.get(i) + ", ");
            } else {
                System.out.print(cardsOnHand.get(i));
            }
        }
        System.out.println("\n");
    }

    public int getChips() {
        return this.chips;
    }

    public void addChips(int amount) {
        this.chips += amount;
    }

    public void deductChips(int amount) {
        if (amount < chips)
            this.chips -= amount;
    }

    public int getTotalCardsValue() {
        int totalValue = 0;
        for (Card card : cardsOnHand) {
            totalValue += card.getValue();
        }
        return totalValue;
    }

    public int getNumberOfCards() {
        return cardsOnHand.size();
    }

    public void clearCardsOnHand() {
        cardsOnHand.clear();
    }
}
public class Keyboard {

	public static String readString(String prompt) {
		System.out.print(prompt);
		return new java.util.Scanner(System.in).nextLine();
	}

	public static int readInt(String prompt) {
		int input = 0;
		boolean valid = false;
		while (!valid) {
			try {
				input = Integer.parseInt(readString(prompt));
				valid = true;
			} catch (NumberFormatException e) {
				System.out.println("*** Please enter an integer ***");
			}
		}
		return input;
	}

	public static double readDouble(String prompt) {
		double input = 0;
		boolean valid = false;
		while (!valid) {
			try {
				input = Double.parseDouble(readString(prompt));
				valid = true;
			} catch (NumberFormatException e) {
				System.out.println("*** Please enter a double ***");
			}
		}
		return input;
	}

	public static float readFloat(String prompt) {
		float input = 0;
		boolean valid = false;
		while (!valid) {
			try {
				input = Float.parseFloat(readString(prompt));
				valid = true;
			} catch (NumberFormatException e) {
				System.out.println("*** Please enter a float ***");
			}
		}
		return input;
	}

	public static long readLong(String prompt) {
		long input = 0;
		boolean valid = false;
		while (!valid) {
			try {
				input = Long.parseLong(readString(prompt));
				valid = true;
			} catch (NumberFormatException e) {
				e.printStackTrace();
				System.out.println("*** Please enter a long ***");
			}
		}
		return input;
	}

	public static char readChar(String prompt) {
		char input = 0;
		boolean valid = false;
		while (!valid) {
			String temp = readString(prompt);
			if (temp.length() != 1) {
				System.out.println("*** Please enter a character ***");
			} else {
				input = temp.charAt(0);
				valid = true;
			}
		}
		return input;
	}

	public static boolean readBoolean(String prompt) {
		boolean valid = false;
		while (!valid) {
			String input = readString(prompt);
			if (input.equalsIgnoreCase("yes") || input.equalsIgnoreCase("y") || input.equalsIgnoreCase("true")
					|| input.equalsIgnoreCase("t")) {
				return true;
			} else if (input.equalsIgnoreCase("no") || input.equalsIgnoreCase("n") || input.equalsIgnoreCase("false")
					|| input.equalsIgnoreCase("f")) {
				return false;
			} else {
				System.out.println("*** Please enter Yes/No or True/False ***");
			}
		}
		return false;
	}

	public static java.util.Date readDate(String prompt) {
		java.util.Date date = null;
		boolean valid = false;
		while (!valid) {
			try {
				String input = readString(prompt).trim();
				if (input.matches("\\d\\d/\\d\\d/\\d\\d\\d\\d")) {
					int day = Integer.parseInt(input.substring(0, 2));
					int month = Integer.parseInt(input.substring(3, 5));
					int year = Integer.parseInt(input.substring(6, 10));
					java.util.Calendar cal = java.util.Calendar.getInstance();
					cal.setLenient(false);
					cal.set(year, month - 1, day, 0, 0, 0);
					date = cal.getTime();
					valid = true;
				} else {
					System.out.println("*** Please enter a date (DD/MM/YYYY) ***");
				}
			} catch (IllegalArgumentException e) {
				System.out.println("*** Please enter a date (DD/MM/YYYY) ***");
			}
		}
		return date;
	}

	private static String quit = "0";

	public static int getUserOption(String title, String[] menu) {
		displayMenu(title, menu);
		int choice = Keyboard.readInt("Enter Choice --> ");
		while (choice > menu.length || choice < 0) {
			choice = Keyboard.readInt("Invalid Choice, Re-enter --> ");
		}
		return choice;
	}

	private static void displayMenu(String title, String[] menu) {
		line(80, "=");
		System.out.println(title.toUpperCase());
		line(80, "-");
		for (int i = 0; i < menu.length; i++) {
			System.out.println("[" + (i + 1) + "] " + menu[i]);
		}
		System.out.println("[" + quit + "] Quit");
		line(80, "-");
	}

	public static void line(int len, String c) {
		System.out.println(String.format("%" + len + "s", " ").replaceAll(" ", c));
	}
}"

Edit the code above as the current output is 
"
HighSum GAME
================================================================================
Enter Login name > pasd
Enter Password > password
================================================================================
pasd, You have 100 chips
--------------------------------------------------------------------------------
Game starts - Dealer shuffles deck.
--------------------------------------------------------------------------------
Dealer dealing cards - ROUND 1
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Dealer dealing cards - ROUND 1
--------------------------------------------------------------------------------
Dealer
<HIDDEN CARD>, <Diamond 4>

pasd
<Spade 8>, <Heart 6>

Value: 14
pasd Wins
--------------------------------------------------------------------------------
Dealer dealing cards - ROUND 2
--------------------------------------------------------------------------------
Dealer
<HIDDEN CARD>, <Diamond 4>

pasd
<Spade 8>, <Heart 6>

Value: 14
pasd Wins
--------------------------------------------------------------------------------
Dealer dealing cards - ROUND 3
--------------------------------------------------------------------------------
Dealer
<HIDDEN CARD>, <Diamond 4>, <Diamond 8>

pasd
<Spade 8>, <Heart 6>, <Diamond Queen>

Value: 24
pasd Wins
--------------------------------------------------------------------------------
Dealer dealing cards - ROUND 4
--------------------------------------------------------------------------------
Dealer
<HIDDEN CARD>, <Diamond 4>, <Diamond 8>, <Diamond King>

pasd
<Spade 8>, <Heart 6>, <Diamond Queen>, <Club Jack>

Value: 34
pasd Wins
================================================================================
pasd, You have 100 chips
--------------------------------------------------------------------------------
Game starts - Dealer shuffles deck.
--------------------------------------------------------------------------------
Dealer dealing cards - ROUND 1
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Dealer dealing cards - ROUND 1
--------------------------------------------------------------------------------
Dealer
<HIDDEN CARD>, <Spade 5>

pasd
<Heart Queen>, <Club Queen>

Value: 20
pasd Wins
--------------------------------------------------------------------------------
Dealer dealing cards - ROUND 2
--------------------------------------------------------------------------------
Dealer
<HIDDEN CARD>, <Spade 5>

pasd
<Heart Queen>, <Club Queen>

Value: 20
pasd Wins
--------------------------------------------------------------------------------
Dealer dealing cards - ROUND 3
--------------------------------------------------------------------------------
Dealer
<HIDDEN CARD>, <Spade 5>, <Heart 3>

pasd
<Heart Queen>, <Club Queen>, <Spade 3>

Value: 23
pasd Wins
--------------------------------------------------------------------------------
Dealer dealing cards - ROUND 4
--------------------------------------------------------------------------------
Dealer
<HIDDEN CARD>, <Spade 5>, <Heart 3>, <Club 8>

pasd
<Heart Queen>, <Club Queen>, <Spade 3>, <Heart Jack>

Value: 33
pasd Wins
================================================================================
pasd, You have 100 chips
--------------------------------------------------------------------------------
Game starts - Dealer shuffles deck.
--------------------------------------------------------------------------------
Dealer dealing cards - ROUND 1
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Dealer dealing cards - ROUND 1
--------------------------------------------------------------------------------
Dealer
<HIDDEN CARD>, <Diamond 7>

pasd
<Diamond Ace>, <Club King>

Value: 11
Dealer Wins
--------------------------------------------------------------------------------
Dealer dealing cards - ROUND 2
--------------------------------------------------------------------------------
Dealer
<HIDDEN CARD>, <Diamond 7>

pasd
<Diamond Ace>, <Club King>

Value: 11
Dealer Wins
--------------------------------------------------------------------------------
Dealer dealing cards - ROUND 3
--------------------------------------------------------------------------------
Dealer
<HIDDEN CARD>, <Diamond 7>, <Club Ace>

pasd
<Diamond Ace>, <Club King>, <Heart Ace>

Value: 12
Dealer Wins
--------------------------------------------------------------------------------
Dealer dealing cards - ROUND 4
--------------------------------------------------------------------------------
Dealer
<HIDDEN CARD>, <Diamond 7>, <Club Ace>, <Diamond 6>

pasd
<Diamond Ace>, <Club King>, <Heart Ace>, <Spade 4>

Value: 16
Dealer Wins
================================================================================
pasd, You have 100 chips
--------------------------------------------------------------------------------
Game starts - Dealer shuffles deck.
--------------------------------------------------------------------------------
Dealer dealing cards - ROUND 1
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Dealer dealing cards - ROUND 1
--------------------------------------------------------------------------------
Dealer
<HIDDEN CARD>, <Diamond 3>

pasd
<Diamond 5>, <Heart King>

Value: 15
pasd Wins
--------------------------------------------------------------------------------
Dealer dealing cards - ROUND 2
--------------------------------------------------------------------------------
Dealer
<HIDDEN CARD>, <Diamond 3>

pasd
<Diamond 5>, <Heart King>

Value: 15
pasd Wins
--------------------------------------------------------------------------------
Dealer dealing cards - ROUND 3
--------------------------------------------------------------------------------
Dealer
<HIDDEN CARD>, <Diamond 3>, <Spade 2>

pasd
<Diamond 5>, <Heart King>, <Spade King>

Value: 25
pasd Wins
--------------------------------------------------------------------------------
Dealer dealing cards - ROUND 4
--------------------------------------------------------------------------------
Dealer
<HIDDEN CARD>, <Diamond 3>, <Spade 2>, <Diamond 2>

pasd
<Diamond 5>, <Heart King>, <Spade King>, <Spade 10>

Value: 35
pasd Wins
================================================================================
pasd, You have 100 chips
--------------------------------------------------------------------------------
Game starts - Dealer shuffles deck.
--------------------------------------------------------------------------------
Dealer dealing cards - ROUND 1
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Dealer dealing cards - ROUND 1
--------------------------------------------------------------------------------
Dealer
<HIDDEN CARD>, <Spade Queen>

pasd
<Club 7>, <Heart 5>

Value: 12
Dealer Wins
--------------------------------------------------------------------------------
Dealer dealing cards - ROUND 2
--------------------------------------------------------------------------------
Dealer
<HIDDEN CARD>, <Spade Queen>

pasd
<Club 7>, <Heart 5>

Value: 12
Dealer Wins
--------------------------------------------------------------------------------
Dealer dealing cards - ROUND 3
--------------------------------------------------------------------------------
Dealer
<HIDDEN CARD>, <Spade Queen>, <Heart 8>

pasd
<Club 7>, <Heart 5>, <Club 2>

Value: 14
Dealer Wins
--------------------------------------------------------------------------------
Dealer dealing cards - ROUND 4
--------------------------------------------------------------------------------
Dealer
<HIDDEN CARD>, <Spade Queen>, <Heart 8>, <Heart 4>

pasd
<Club 7>, <Heart 5>, <Club 2>, <Heart 7>

Value: 21
Dealer Wins
================================================================================
pasd, You have 100 chips
--------------------------------------------------------------------------------
Game starts - Dealer shuffles deck.
--------------------------------------------------------------------------------
Dealer dealing cards - ROUND 1
--------------------------------------------------------------------------------"
with these errors
"Exception in thread "main" java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0
	at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64)
	at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70)
	at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:266)
	at java.base/java.util.Objects.checkIndex(Objects.java:359)
	at java.base/java.util.ArrayList.remove(ArrayList.java:504)
	at Deck.dealCard(Deck.java:40)
	at GameModule.main(GameModule.java:33)"

The code is supposed to go round by round and asking the player to place bet if their card is bigger than the dealer's and there should be an option of "Do you want to [C]all or [Q]uit?: " for each round and  C is for continuing the game and q is to end the game.