Skip to content
Snippets Groups Projects
Commit fac5488b authored by emilruud's avatar emilruud
Browse files

Removed borders, and made it so that card analyticts resets when dealing a new hand.

parent 1b1ec4aa
No related branches found
No related tags found
No related merge requests found
......@@ -21,11 +21,10 @@ import no.ntnu.idatx2003.oblig3.cardgame.model.PlayingCard;
public class CardGameGUI extends Application {
private HBox cardsBox;
private BorderPane root;
private HandofCards currentHand; // Make currentHand a class member variable
private Text sumTextLabel;
private Label sumNumberLabel;
private Label sumNumberLabel;
private Label flushLabel;
......@@ -35,11 +34,11 @@ public class CardGameGUI extends Application {
@Override
public void start(Stage primaryStage) {
root = new BorderPane(); // Initialize root as a BorderPane
cardsBox = new HBox(20); // Initialize cardsBox as an HBox with spacing of 20
cardsBox.setStyle("-fx-border-color: red; -fx-border-width: 2;"); // Set border for cardsBox
BorderPane root = new BorderPane(); // Initialize root as a BorderPane
cardsBox = new HBox(20); // Initialize cardsBox as an HBox with spacing of 20
cardsBox.setAlignment(Pos.CENTER); // Set the alignment of the HBox to CENTER
cardsBox.setPadding(new Insets(10, 10, 20, 10));
//cardsBox.setStyle("-fx-border-color: red; -fx-border-width: 2;"); // Set border for cardsBox
root.setTop(cardsBox); // Add cardsBox to the left region of the BorderPane
......@@ -49,7 +48,7 @@ public class CardGameGUI extends Application {
Scene scene = new Scene(root, 800, 500);
primaryStage.setTitle("Card Game");
sumTextLabel = new Text("Sum of the faces: ");
Text sumTextLabel = new Text("Sum of the faces: ");
sumNumberLabel = new Label("0 ");
HBox sumBox = new HBox(sumTextLabel, sumNumberLabel);// Create a HBox
VBox leftBox = new VBox(sumBox);
......@@ -62,21 +61,21 @@ public class CardGameGUI extends Application {
leftBox.setAlignment(Pos.TOP_LEFT); // Set the alignment of the VBox to CENTER
leftBox.setPadding(new Insets(10, 10, 10, 10));
leftBox.setStyle("-fx-border-color: blue; -fx-border-width: 2;"); // Set border for leftBox
//leftBox.setStyle("-fx-border-color: blue; -fx-border-width: 2;"); // Set border for leftBox
leftBox.setSpacing(20);
Text flushText = new Text("Flush: ");
flushLabel = new Label(" ");
HBox flushBox = new HBox(flushText, flushLabel); // Create a HBox
flushBox.setPadding(new Insets(10, 10, 10, 10));
flushBox.setStyle("-fx-border-color: green; -fx-border-width: 2;");
//flushBox.setStyle("-fx-border-color: green; -fx-border-width: 2;");
VBox rightBox = new VBox(flushBox);
Text heartsText = new Text("Cards of Hearts: ");
heartsLabel = new Label(" ");
HBox heartsBox = new HBox(heartsText, heartsLabel); // Create a HBox
heartsBox.setPadding(new Insets(10, 10, 10, 10));
heartsBox.setStyle("-fx-border-color: green; -fx-border-width: 2;");
//heartsBox.setStyle("-fx-border-color: green; -fx-border-width: 2;");
rightBox.getChildren().add(heartsBox);
......@@ -85,13 +84,17 @@ public class CardGameGUI extends Application {
analytics.setSpacing(20);
analytics.setPadding(new Insets(50, 10, 100, 10));
analytics.setAlignment(Pos.BOTTOM_LEFT);
analytics.setStyle("-fx-border-color: red; -fx-border-width: 2;");
//analytics.setStyle("-fx-border-color: red; -fx-border-width: 2;");
root.setBottom(analytics);
Button dealButton = new Button("Deal a new hand");
dealButton.setOnAction(event -> {
sumNumberLabel.setText("0");
flushLabel.setText(" ");
queenOfSpadesLabel.setText(" ");
heartsLabel.setText(" ");
DeckOfCards deck = new DeckOfCards();
currentHand = deck.dealHand(5);
displayHand(currentHand);
......@@ -110,7 +113,7 @@ public class CardGameGUI extends Application {
buttonBox.setAlignment(Pos.TOP_RIGHT); // Set the alignment of the VBox to CENTER
buttonBox.getChildren().add(dealButton); // Add the button to the VBox
buttonBox.getChildren().add(CheckButton); // Add the button to the VBox
buttonBox.setStyle("-fx-border-color: blue; -fx-border-width: 2;"); // Set border for rightBox
//buttonBox.setStyle("-fx-border-color: blue; -fx-border-width: 2;"); // Set border for rightBox
root.setRight(buttonBox); // Add the VBox to the right region of the BorderPane
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment