Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

JAVAFX Description HiLo is a card game where a card is dealt and the player has

ID: 3711588 • Letter: J

Question

JAVAFX

Description

HiLo is a card game where a card is dealt and the player has to guess whether the next card that is dealt will be higher or lower than the first card. In the application a card is first dealt on the left hand side. Then, a guess as to whether the next card dealt will be higher or lower is indicated, using the radio buttons in the centre. On clicking the 'Deal Second Card' button, another card is dealt on the right hand side. If the card dealt is in accordance with the guess of the user, then the user wins. Five consecutive, correct guesses constitute an overall game win. A new game is begun using the menu by selecting the 'New Game' item. Note that for the purpose of comparing cards, only the face of the card matters. The suit, i.e, whether Hearts, Spades, Clubs, etc., is unimportant. A second card of equal face value is considered a lose for the purposes of this game.

Requirement

1. Create a project called 'CardsHiLoGUI'. Create a main interface for the application. Remember to create a ToggleGroup for the radio buttons and set the ToggleGroup for each button to ensure mutual exclusivity. At application startup, the card images are populated with default cards. Use comments in your code to explain your approach in relation to the GUI construction.

2. Add a menu bar and 'File' menu. The 'File' menu should contain the items 'New Game', 'Shuffle' and 'Exit'. Implement these menu items fully. Add a 'Help' menu with an 'About' item to show your student name and number in a dialog.

3. Create classes for 'Card' and 'DeckOfCards' to help manage the game. The Card class should include methods such as 'isEqual( )', 'isLower( )', 'isHigher( )' and

'toString( )'. DeckOfCards should include methods such as 'dealTopCard( )', 'isEmpty( )' and 'shuffle( )'. Provide one or more constructors as appropriate for

each class.

4. Implement dealing of each card, determination of a win/lose and user feedback in a label. Store wins and inform the user of an overall game win on achieving 5 consecutive, correct guesses.

5. Add a progress bar and progress indicator to indicate progress towards 5 consecutive wins leading to an overall game win. Provide appropriate feedback on achieving an overall game win. Use a stylesheet to apply an attractive look and feel to the application.

I have completed number 1 and 2, I need help with number 3 please.

Code so far:

package cardshilogui;

import java.io.FileInputStream;
import javafx.application.Application;
import javafx.geometry.HPos;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.Menu;
import javafx.scene.control.MenuBar;
import javafx.scene.control.MenuItem;
import javafx.scene.control.RadioButton;
import javafx.scene.control.ToggleGroup;

import javafx.scene.layout.BorderPane;
import javafx.scene.layout.GridPane;
import javafx.stage.Stage;
import javafx.scene.layout.VBox;
import javafx.scene.layout.HBox;
import javafx.scene.image.ImageView;
import javafx.scene.image.Image;
import javafx.stage.Modality;
import javafx.scene.text.TextAlignment;
import javafx.scene.control.ProgressBar;
import javafx.application.Platform;

public class CardsHiLoGUI extends Application {

//Label Constructors
Label firstCardDealt = new Label("First Card Dealt:");
Label secondCardDealt = new Label("Second Card Dealt:");
Label nextCardDealt = new Label("Next Card Dealt:");
Label higherYouWin = new Label("Higher You Win!");
Label higherYouLose = new Label("Lower You Lose!");
Label lowerYouWin = new Label("Lower You Win!");
Label lowerYouLose = new Label("Lower You Lose!");
Label nextCardWillBe = new Label("Next card will be: ");

// Button Constructors
Button dealFirstCardB = new Button("<- Deal First Card");
Button dealSecondCardB = new Button("Deal Second Card ->");

// Radio Button Constructors
RadioButton higherRB = new RadioButton("Higher");
RadioButton lowerRB = new RadioButton("Lower");

// Toggle Group Constructor
ToggleGroup radioGroup = new ToggleGroup();

BorderPane root = new BorderPane();

// Vertical box Constructor (to put in centre with a GridPane layout)
GridPane grid = new GridPane();
VBox centreBox = new VBox(10);

// Horizontal Box construtor (to hold menubar)
HBox menuBox = new HBox();

// MenuBar constructor
MenuBar menuBar = new MenuBar();

// Constructing File Menu and menu items
Menu fileMenu = new Menu("File");
MenuItem newGame = new MenuItem("New Game");
MenuItem shuffle = new MenuItem("Shuffle");
MenuItem exit = new MenuItem("Exit");

// Constructing Help menu
Menu helpMenu = new Menu("Help");
MenuItem about = new MenuItem("About");

// Constructing ToggleGroup
ToggleGroup group = new ToggleGroup();
//Constructing a vertical box to host radio buttons
VBox radioBox = new VBox(10);

Image king_of_clubs = new Image("/cards/king_of_clubs.png");
Image hearts = new Image("/cards/4_of_hearts.png");
ImageView imageView1 = new ImageView(king_of_clubs);
ImageView imageView2 = new ImageView(hearts);

HBox hbox1 = new HBox(imageView1);

HBox hbox2 = new HBox(imageView2);

//Image Constructor
//FileInputStream input = new FileInputStream("");
//Image image = new Image("king_of_hearts.png");
// ImageView imageView1 = new ImageView(image);
//imageView1.setImage(image);
// HBox hbox = new HBox(imageView1);
//HBox hbox = new HBox(imageView1);
//ImageView Constructor
@Override
public void start(Stage primaryStage) throws Exception {
setToggleGroup();
addComponents();
setScene(primaryStage);
setSpacing();
//FileInputStream input = new FileInputStream("/Users/johnoleary/NetBeansProjects/CardsHiLoGUI/src/cards/king_of_clubs.png");

imageView1.setImage(king_of_clubs);
root.setLeft(hbox1);
root.setRight(hbox2);

}

public void addComponents() {
// Adding menubox to top of borderPane
root.setTop(menuBox);
// Insering menuBar into menuBox
menuBox.getChildren().add(menuBar);
// Adding menu items to fileMenu
fileMenu.getItems().addAll(newGame, shuffle, exit);
// Adding menu items to helpMenu
helpMenu.getItems().addAll(about);
// Adding menus to the menu bar
menuBar.getMenus().addAll(fileMenu, helpMenu);
// Adding a VBox to center of borderpane
root.setCenter(centreBox);
// Adding gridpane layout to this verticalBox
centreBox.getChildren().add(grid);
// Adding elements/nodes to the grid
grid.add(nextCardWillBe, 0, 1);
grid.add(radioBox, 0, 2);
radioBox.getChildren().add(higherRB);
radioBox.getChildren().add(lowerRB);
higherRB.setSelected(true);

grid.add(dealFirstCardB, 0, 3);
grid.add(dealSecondCardB, 0, 5);

}

public void setToggleGroup() {
higherRB.setToggleGroup(group);
lowerRB.setToggleGroup(group);

}

public void setSpacing() {
grid.setAlignment(Pos.CENTER);
grid.setHgap(10);
grid.setVgap(10);
grid.setPadding(new Insets(0, 25, 25, 25));

// hbBtn.setAlignment(Pos.BOTTOM_LEFT);
// Centering our heading label
// root.setHalignment(headingLabel, HPos.CENTER);
}

public void setScene(Stage primaryStage) {
Scene scene = new Scene(root, 500, 350); // width
primaryStage.setScene(scene);
primaryStage.setTitle("Hi-Lo Card Game");
primaryStage.show();

}

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}

}

Explanation / Answer

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.stage.Modality;
import javafx.stage.Stage;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.VBox;
import javafx.scene.text.TextAlignment;

import javafx.scene.control.Button;
import javafx.scene.control.RadioButton;
import javafx.scene.control.ToggleGroup;
import javafx.scene.control.Label;

import javafx.scene.control.MenuBar;
import javafx.scene.control.Menu;
import javafx.scene.control.MenuItem;
import javafx.scene.control.ProgressBar;
import javafx.geometry.Pos;
import javafx.geometry.Insets;

import javafx.scene.image.ImageView;
import javafx.scene.image.Image;

import javafx.application.Platform;

public class CardsHiLoGUI extends Application {

    Label lblFirstCard, lblSecondCard, lblPrompt, lblResult, lblpBar;

    Image imgFirstCard, imgSecondCard;

    ImageView imvFirstCard, imvSecondCard;

    Button btnDealFirst, btnDealSecond;

    RadioButton rdoHigher, rdoLower;
    ToggleGroup hiloGroup;

    MenuBar mBar;

    Menu menuFile;
    Menu menuAbout;

    MenuItem mItemNew;
    MenuItem mItemShuffle;
    MenuItem mItemExit;
    MenuItem mItemAbout;

    // Progressbar
    ProgressBar pBar;


    public CardsHiLoGUI() {
    }

    public void init() {

        // create Game
        Game game = new Game();

        // Labels
        lblFirstCard = new Label("First Card Dealt:");
        lblSecondCard = new Label("Second Card Dealt:");
        lblPrompt = new Label("The next Card will be:");
        lblResult = new Label("The result is:");
        lblpBar = new Label("5 correct guesses in a row needed to win");

        // Images
        imgFirstCard = new Image(getClass().getResource("cards.png").toString());

        imgSecondCard = new Image(getClass().getResource(" cards.png").toString());

        imvFirstCard = new ImageView(imgFirstCard);
        imvSecondCard = new ImageView(imgSecondCard);

        // Buttons
        btnDealFirst = new Button("<- Deal First Card");
        btnDealFirst.setOnAction(ae -> btnFirstClick(game));

        btnDealSecond = new Button("Deal Second Card ->");

        // Configure button size
        btnDealFirst.setMinWidth(160);
        btnDealSecond.setMinWidth(160);
        btnDealSecond.setDisable(true);
        btnDealSecond.setOnAction(ae -> btnSecondClick(game));

        // Instantiate radio buttons
        rdoHigher = new RadioButton("Higher");
        rdoLower = new RadioButton("Lower");

        hiloGroup = new ToggleGroup();
        rdoHigher.setToggleGroup(hiloGroup);
        rdoLower.setToggleGroup(hiloGroup);
        rdoHigher.setSelected(true);

        // Menu
        mBar = new MenuBar();
        menuFile = new Menu("File");
        menuAbout = new Menu("About");

        // menu item new game
        mItemNew = new MenuItem("New game");
        mItemNew.setOnAction(ae -> gameStart(game));

        // menu item exit game
        mItemExit = new MenuItem("Exit");
        mItemExit.setOnAction(ae -> Platform.exit());

        // menu item about
        mItemAbout = new MenuItem("About");
        mItemAbout.setOnAction(ae -> showAbout());

        // add menus to menu bar
        mBar.getMenus().add(menuFile);
        mBar.getMenus().add(menuAbout);

        // add entries to menu
        menuFile.getItems().add(mItemNew);
        menuFile.getItems().add(mItemExit);
        menuAbout.getItems().add(mItemAbout);

        // Progress bar
        pBar = new ProgressBar(0);
        pBar.setPrefWidth(480);

    }// init

    @Override
    public void start(Stage primaryStage) throws Exception {
        // Set the title
        primaryStage.setTitle("Cards HiLo Game");

        // Create a layout
        GridPane gp = new GridPane();

        gp.add(lblFirstCard, 0, 0);
        gp.add(lblSecondCard, 2, 0);
        gp.add(lblPrompt, 1, 1);

        // Vbox
        VBox playButtonBox = new VBox();
        VBox vBoxMain = new VBox();
        VBox vBoxUpper = new VBox();

        vBoxUpper.getChildren().add(lblpBar);
        vBoxUpper.getChildren().add(pBar);

        vBoxMain.getChildren().add(mBar);
        vBoxMain.getChildren().add(vBoxUpper);
        vBoxMain.getChildren().add(gp);

        // Padding & Spacing
        gp.setVgap(10);
        gp.setHgap(10);
        gp.setAlignment(Pos.BASELINE_CENTER);
        gp.setPadding(new Insets(10));

        playButtonBox.setPadding(new Insets(5));
        vBoxUpper.setPadding(new Insets(10));
        playButtonBox.setSpacing(5);
        vBoxUpper.setSpacing(5);

        // add images
        gp.add(imvFirstCard, 0, 1);
        gp.add(imvSecondCard, 2, 1);

        playButtonBox.getChildren().add(lblPrompt);
        playButtonBox.getChildren().add(rdoHigher);
        playButtonBox.getChildren().add(rdoLower);
        playButtonBox.getChildren().add(btnDealFirst);
        playButtonBox.getChildren().add(btnDealSecond);

        gp.add(playButtonBox, 1, 1);

        // Create a scene
        Scene scene = new Scene(vBoxMain, 500, 350);
        scene.getStylesheets().add("./stylesheet.css");
        // Set the scene
        primaryStage.setScene(scene);

        // Show the stage
        primaryStage.show();

    }

    public void stop() {

    }// stop

    public void showAbout() {

        // create stage
        Stage stageAbout = new Stage();

        // set title
        stageAbout.setTitle("About");

        // create vbox and label for stage
        VBox vBoxAbout = new VBox();

        vBoxAbout.setPadding(new Insets(10));
        vBoxAbout.setAlignment(Pos.TOP_CENTER);

        // create button ok and Label
        Button btnOK = new Button("OK");

        // Create and style label for about box
        Label lblAbout = new Label("Cards Hi Low Game");
        lblAbout.setPadding(new Insets(10));
        lblAbout.setTextAlignment(TextAlignment.CENTER);

        // add label and button to about box
        vBoxAbout.getChildren().add(lblAbout);
        vBoxAbout.getChildren().add(btnOK);

        // when button clicked, close about box
        btnOK.setOnAction(ae -> stageAbout.close());

        // create scene
        Scene sceneAbout = new Scene(vBoxAbout);
        sceneAbout.getStylesheets().add("./stylesheet.css");

        // set scene
        stageAbout.setScene(sceneAbout);

        // show stage
        stageAbout.show();

    } // show about

    /*
     * Method to handle end of game
     */
    public void alertGameEnd(Game game) {
        // create stage
        Stage stageAlert = new Stage();

        // set title
        stageAlert.setTitle("Alert");

        // create vbox and label for stage
        VBox vBoxAlert = new VBox();

        vBoxAlert.setPadding(new Insets(10));
        vBoxAlert.setAlignment(Pos.TOP_CENTER);

        // create button ok and Label
        Button btnOK = new Button("OK");

        Label lblAlert = new Label("You ran out of cards. Start new Game");
        lblAlert.setPadding(new Insets(10));
        lblAlert.setTextAlignment(TextAlignment.CENTER);

        vBoxAlert.getChildren().add(lblAlert);
        vBoxAlert.getChildren().add(btnOK);

        // close dialog when ok button is clicked
        btnOK.setOnAction(ae -> {
            game.restart();
            stageAlert.close();
        });

        // create scene
        Scene sceneAlert = new Scene(vBoxAlert);
        sceneAlert.getStylesheets().add("./stylesheet.css");

        // set scene
        stageAlert.setScene(sceneAlert);

        // show stage
        stageAlert.show();

    } // show alert

    /*
     * Method to show a dialog with a message (wrong/correct)
     */
    public void showMessage(String message, Game game) {
        // create stage
        Stage stageMessage = new Stage();

        // set title
        stageMessage.setTitle("Info");

        // create vbox and label for stage
        VBox vBoxMessage = new VBox();

        vBoxMessage.setPadding(new Insets(10));
        vBoxMessage.setAlignment(Pos.TOP_CENTER);
        vBoxMessage.setMinWidth(150);

        // create button ok and Label
        Button btnOK = new Button("OK");

        // create and style label
        Label lblMessage = new Label(message);
        lblMessage.setPadding(new Insets(10));
        lblMessage.setTextAlignment(TextAlignment.CENTER);

        // add label to vbox
        vBoxMessage.getChildren().add(lblMessage);
        vBoxMessage.getChildren().add(btnOK);

        // on click close dialog
        btnOK.setOnAction(ae -> {
            btnFirstClick(game);
            stageMessage.close();
        });

        // create scene
        Scene sceneMessage = new Scene(vBoxMessage);
        sceneMessage.getStylesheets().add("./stylesheet.css");

        // set scene
        stageMessage.setScene(sceneMessage);

        // show stage
        stageMessage.show();

    } // show Message

    // when the first button is clicked
    public void btnFirstClick(Game game) {

        // print out current and next card for debugging
        // System.out.println("Current Card before dealing card 1: " +
        // game.getDeck().getCurrentCard());
        // System.out.println("Next Card before dealing card 1: " +
        // game.getDeck().getNextCard());

        // take a card from the top of the deck
        Card card = game.getDeck().dealTopCard();

        // store the card in firstCard variable
        game.getDeck().setFirstCard(card);
        // System.out.println("First card: "+ card.toString());

        // change image to display the first card
        Image img1 = new Image(getClass().getResource(card.toString()).toString());
        imvFirstCard.setImage(img1);

        // show default image in second card imageview
        Image img2 = new Image(getClass().getResource("cards.png").toString());
        imvSecondCard.setImage(img2);

        // disable button 1 and enable button 2
        btnDealFirst.setDisable(true);
        btnDealSecond.setDisable(false);

        // print for debugging
        // System.out.println("Current Card after dealing card 1: " +
        // game.getDeck().getCurrentCard());
        // System.out.println("Next Card after dealing card 1: " +
        // game.getDeck().getNextCard());

    } // buttonFirstClick

    public void btnSecondClick(Game game) {

        // when second button is clicked
        // deal top card
        Card card = game.getDeck().dealTopCard();
        System.out.println("Second Card: " + card.toString());

        // store card in variable secondCard
        game.getDeck().setSecondCard(card);

        // show image of second card
        Image img2 = new Image(getClass().getResource(card.toString()).toString());
        imvSecondCard.setImage(img2);

        // disable second button and enable first
        btnDealSecond.setDisable(true);
        btnDealFirst.setDisable(false);
        System.out.println("Current Card after dealing second card: " + game.getDeck().getCurrentCard());
        System.out.println("Next Card after dealing second card: " + game.getDeck().getNextCard());

        // variable to store a win
        boolean isWinner = false;
        // if radiobutton lower is selected, evaluate win for this situation
        if (rdoLower.isSelected()) {
            if (game.evaluateWin(0) == true) {
                isWinner = true;
            }
            // if radiobutton higher is selected, evaluate win for this
            // situation
        } else if (rdoHigher.isSelected()) {
            if (game.evaluateWin(1) == true) {
                isWinner = true;
            }
            ;
        }
        // if player won, but win counter has not reached 5, show message
        // correct
        if (isWinner == true&& (game.getWinCounter() < 5)) {

            showMessage("Correct", game);

            // else show message wrong
        } else if (isWinner == false) {
            showMessage("Wrong", game);

        }

        // update progress bar with win counter value
        pBar.setProgress((double) game.getWinCounter() / 5);
        // if user won 5 times, show message and restart game
        if (game.getWinCounter() == 5) {
            showMessage("You won the game. Play again", game);
            gameStart(game);

        }

        // check if deck is empty, if so alert end of game
        if (game.getDeck().isEmpty() == true) {
            alertGameEnd(game);
            // restart game
            gameStart(game);
        }

    }// btnSecondClick()

    public void gameStart(Game game) {
        // reset all counters
        game.restart();

        // replace both imv with default image
        Image img = new Image(getClass().getResource("cards.png").toString());
        imvFirstCard.setImage(img);
        imvSecondCard.setImage(img);
        // reset buttons and progress bar
        btnDealSecond.setDisable(true);
        btnDealFirst.setDisable(false);
        pBar.setProgress(0);

    }// gamestart()

    public static void main(String[] args) {
        // launch the application

        launch(args);

    }

}
--------------------------------------------------------------------
public class Card {
    private int rank;
    private int suit;


    public Card() {
        // TODO Auto-generated constructor stub
    }


    public Card(int rank, int suit) {
        super();
        this.rank = rank;
        this.suit = suit;
    }

    public String toString() {
        String cardSuit = "";
        String cardRank = "";
        String cardString;
        // get suit and rank for the card
        int cs = getSuit();
        int cr = getRank();

        // convert to a string. First suit
        switch (cs) {
            case 0: cardSuit="hearts";
                break;
            case 1: cardSuit="diamonds";
                break;
            case 2: cardSuit="clubs";
                break;
            case 3: cardSuit="spades";
                break;
            default: cardSuit="n/a";

        }// switch

        switch (cr) {
            case 1: cardRank="ace";
                break;
            case 2: cardRank="2";
                break;
            case 3: cardRank="3";
                break;
            case 4: cardRank="4";
                break;
            case 5: cardRank="5";
                break;
            case 6: cardRank="6";
                break;
            case 7: cardRank="7";
                break;
            case 8: cardRank="8";
                break;
            case 9: cardRank="9";
                break;
            case 10:cardRank="10";
                break;
            case 11:cardRank="jack";
                break;
            case 12:cardRank="queen";
                break;
            case 13:cardRank="king";
                break;
            default:cardRank="n/a";

        } // switch rank

        cardString = "./cards/" + cardRank + "_of_" + cardSuit + ".png";
        return cardString;

    }

    public boolean rankIsLessThan (Card second){
        if (this.rank < second.getRank()){
            return true;
        } else {
            return false;
        }

    }

    public boolean rankIsGreaterThan (Card second){
        if (this.rank > second.getRank()){
            return true;
        } else {
            return false;
        }

    }

    public int getRank() {
        return rank;
    }


    public void setRank(int rank) {
        this.rank = rank;
    }


    public int getSuit() {
        return suit;
    }


    public void setSuit(int suit) {
        this.suit = suit;
    }

}
------------------------------------------------------
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class DeckOfCards {
    private int currentCard;
    private int nextCard;
    private int[] suits;
    private int[] ranks;
    private Card[] deck;
    private Card firstCard;
    private Card secondCard;

    public DeckOfCards() {
        super();

        // create arrays to hold suits and ranks
        this.suits = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
                1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 };
        this.ranks = new int[] { 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0,
                1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3 };
        // create array to hold all dealt cards and all 52 cards
        this.deck = new Card[52];

        for (int i = 0; i< this.deck.length; i++) {
            this.deck[i] = new Card(suits[i], ranks[i]);
        }

        // setting current card and next card to 0
        this.currentCard = 0;
        this.nextCard = 1;
    }

    // Method to shuffle the deck
   
    public void shuffle() {
        Card tempStore;

        for (int i = 0; i< this.deck.length; i++) {
            int random = (int) ((Math.random() * 52));
            tempStore = deck[i];
            deck[i] = deck[random];
            deck[random] = tempStore;
        } // for
    } // shuffle

    // method to check if the all cards have been dealt
    public boolean isEmpty() {
        if (this.nextCard > 50) {
            return true;
        } else {
            return false;
        }
    } // isEmpty

    // method to deal next card
    public Card dealTopCard() {

        this.nextCard++;
        this.currentCard = nextCard - 1;
        return deck[currentCard];
    } // dealTopCard

    public int getCurrentCard() {
        return currentCard;
    }

    public void setCurrentCard(int currentCard) {
        this.currentCard = currentCard;
    }

    public int getNextCard() {
        return nextCard;
    }

    public void setNextCard(int nextCard) {
        this.nextCard = nextCard;
    }

    public Card getFirstCard() {
        return firstCard;
    }

    public void setFirstCard(Card firstCard) {
        this.firstCard = firstCard;
    }

    public Card getSecondCard() {
        return secondCard;
    }

    public void setSecondCard(Card secondCard) {
        this.secondCard = secondCard;
    }
}
----------------------------------------------------------------------
public class Game {

    // variables Deck and a counter to keep track of the consecutive wins
    private DeckOfCards deck;
    private int winCounter;

    // Constructor
    public Game() {
        super();
        this.deck = new DeckOfCards();
        deck.shuffle();
        this.winCounter = 0;
    }

    // method to evaluate if the player won the round
    public boolean evaluateWin(int hiLo) {
        // if lower was selected
        if (hiLo == 0) {
            // if the second card is lower than the first card
            if (this.deck.getSecondCard().rankIsLessThan(this.getDeck().getFirstCard())) {
                this.winCounter++; // increment win counter
                return true;
            } else {
                this.winCounter = 0; // else set win counter to 0
                return false;
            }
            // if higher was selected
        } else if (hiLo == 1) {
            // test if second card is higher
            if (this.deck.getSecondCard().rankIsGreaterThan(this.deck.getFirstCard())) {
                // increment win counter
                this.winCounter++;
                return true;
            } else {
                // or reset win counter
                this.winCounter = 0;
                return false;
            }
        } else {
            this.winCounter = 0;
            return false;
        }
    }

    // when the game is restarted
    public void restart() {
        // reset all counters
        winCounter = 0;
        deck.shuffle();
        this.getDeck().setCurrentCard(0);
        this.getDeck().setNextCard(0);
        this.getDeck().setFirstCard(null);
        this.getDeck().setSecondCard(null);
    }

    public DeckOfCards getDeck() {
        return deck;
    }

    public void setDeck(DeckOfCards deck) {
        this.deck = deck;
    }

    public int getWinCounter() {
        return winCounter;
    }

    public void setWinCounter(int winCounter) {
        this.winCounter = winCounter;
    }

}
------------------------------------------------------------------
//stylesheet.css

.root{
    -fx-base: rgb(21, 225, 15);
    -fx-background: rgb(0, 0, 0);
}

.button {
   -fx-base: rgb(224, 224, 224);
}