@Override
    public void actionPerformed(ActionEvent e) {

        String command = e.getActionCommand();
        switch (command) {
            case "deal":
                if (!playerPurse.betAcceptable()) {
                    ui.gameOver("Choose smaller bet!");
                    return;
                }
                dealPressed();
                if (checkBlackJack()) {
                    command = "bust";
                }
                ui.splitButton.setEnabled(playerHand.isSplittable());
                break;
            case "hit":
                hitPressed();
                break;
            case "stay":
                if (playingSplitHand) {
                    setEnableSplitHand(false);
                    // if the playerHand is blackjack, the game ends.
                    if (playerHand.blackJack()) {
                        ui.stayButton.doClick();
                        return;
                    }
                    return;
                }
                stayPressed();
                break;
            case "split":
                splitPressed();
                break;
            case "double":
                doubleHand(playerHand);
        }
        ui.setEnableButton(command);
    }