Skip to content
Snippets Groups Projects
Commit dd3a182f authored by Ina Martini's avatar Ina Martini
Browse files

Did some style-changes in Gui-class

parent d7341e79
Branches master
No related tags found
No related merge requests found
...@@ -77,9 +77,6 @@ public class DeckOfCards { ...@@ -77,9 +77,6 @@ public class DeckOfCards {
Random random = new Random(); Random random = new Random();
ArrayList<PlayingCard> hand = new ArrayList<>(); ArrayList<PlayingCard> hand = new ArrayList<>();
if (deck.size() < n) {
n = deck.size();
}
if (n <= 0) { if (n <= 0) {
throw new IllegalArgumentException("Number of cards must be greater than 0"); throw new IllegalArgumentException("Number of cards must be greater than 0");
} }
......
...@@ -41,21 +41,18 @@ public class GUI extends Application { ...@@ -41,21 +41,18 @@ public class GUI extends Application {
//text for flush //text for flush
Text t = new Text("Flush:"); Text t = new Text("Flush:");
t.setTranslateX(100); t.setTranslateX(100);
t.setTranslateY(220); t.setTranslateY(230);
t.setFill(Color.web("#fa9446")); t.setFill(Color.web("#e8692a"));
t.setStyle("-fx-font-size: 16px;");
//text for straight
Text s = new Text("Straight:");
s.setTranslateX(100);
s.setTranslateY(400);
s.setFill(Color.web("#fa9446"));
TextArea textArea = new TextArea(); TextArea textArea = new TextArea();
textArea.setTranslateX(50); textArea.setTranslateX(50);
textArea.setTranslateY(-50); textArea.setTranslateY(-50);
textArea.setMaxWidth(400); textArea.setMaxWidth(410);
textArea.setMaxHeight(200); textArea.setMaxHeight(200);
textArea.setEditable(false); textArea.setEditable(false);
textArea.setStyle("-fx-background-color: #7612ff; -fx-control-inner-background: #ddc4ff; " +
"-fx-text-fill: #7612ff; -fx-font-size: 16px;");
TextArea smallTextArea = new TextArea(); TextArea smallTextArea = new TextArea();
smallTextArea.setTranslateX(160); smallTextArea.setTranslateX(160);
...@@ -63,13 +60,8 @@ public class GUI extends Application { ...@@ -63,13 +60,8 @@ public class GUI extends Application {
smallTextArea.setMaxWidth(100); smallTextArea.setMaxWidth(100);
smallTextArea.setMaxHeight(10); smallTextArea.setMaxHeight(10);
smallTextArea.setEditable(false); smallTextArea.setEditable(false);
smallTextArea.setStyle("-fx-background-color: #e8692a; -fx-control-inner-background: #ffe79e; " +
TextArea newSmallTextArea = new TextArea(); "-fx-text-fill: #e8692a; -fx-font-size: 16px;");
newSmallTextArea.setTranslateX(160);
newSmallTextArea.setTranslateY(300);
newSmallTextArea.setMaxWidth(100);
newSmallTextArea.setMaxHeight(10);
newSmallTextArea.setEditable(false);
//buttons----------------------------------------------------------------- //buttons-----------------------------------------------------------------
...@@ -87,8 +79,7 @@ public class GUI extends Application { ...@@ -87,8 +79,7 @@ public class GUI extends Application {
button.setDisable(true); button.setDisable(true);
} }
}); });
button.setTextFill(Color.web("#fc0380")); button.setStyle("-fx-text-fill: #fc0380; -fx-background-color: #ffc2e1; -fx-border-color: #fc0380;");
button.setStyle("-fx-background-color: #ffc2e1;");
Button button2 = new Button("Check hand"); Button button2 = new Button("Check hand");
button2.setTranslateX(500); button2.setTranslateX(500);
...@@ -98,11 +89,9 @@ public class GUI extends Application { ...@@ -98,11 +89,9 @@ public class GUI extends Application {
textArea.setText("You have to reset the deck before you can check the hand"); textArea.setText("You have to reset the deck before you can check the hand");
} else { } else {
smallTextArea.setText(hand.checkFlush()); smallTextArea.setText(hand.checkFlush());
newSmallTextArea.setText(hand.checkStraight());
} }
}); });
button2.setTextFill(Color.web("#0056bd")); button2.setStyle("-fx-text-fill: #0056bd; -fx-background-color: #90b8e8; -fx-border-color: #0056bd;");
button2.setStyle("-fx-background-color: #90b8e8;");
Button button3 = new Button("Reset deck"); Button button3 = new Button("Reset deck");
button3.setTranslateX(500); button3.setTranslateX(500);
...@@ -113,15 +102,14 @@ public class GUI extends Application { ...@@ -113,15 +102,14 @@ public class GUI extends Application {
smallTextArea.setText(""); smallTextArea.setText("");
button.setDisable(false); button.setDisable(false);
}); });
button3.setTextFill(Color.web("#11660b")); button3.setStyle("-fx-text-fill: #11660b; -fx-background-color: #9ee899; -fx-border-color: #11660b;");
button3.setStyle("-fx-background-color: #9ee899;");
//------------------------------------------------------------------------ //------------------------------------------------------------------------
//new vbox //new vbox
VBox vBox = new VBox(); VBox vBox = new VBox();
//add buttons and text to vbox //add buttons and text to vbox
vBox.getChildren().addAll(button, button2, button3, t, smallTextArea, textArea, s, newSmallTextArea); vBox.getChildren().addAll(button, button2, button3, t, smallTextArea, textArea);
//add stackpane to scrollpane //add stackpane to scrollpane
scrollPane.setContent(vBox); scrollPane.setContent(vBox);
......
...@@ -33,6 +33,12 @@ public class HandOfCards { ...@@ -33,6 +33,12 @@ public class HandOfCards {
return handOfCards; return handOfCards;
} }
/**
* Returns the hand of cards as a String.
*
* @param handOfCards the hand of cards as an ArrayList
* @return the hand of cards as a String
*/
public String getHandWithCards(ArrayList<PlayingCard> handOfCards) { public String getHandWithCards(ArrayList<PlayingCard> handOfCards) {
StringBuilder hand = new StringBuilder(); StringBuilder hand = new StringBuilder();
for (PlayingCard card : handOfCards) { for (PlayingCard card : handOfCards) {
...@@ -52,23 +58,4 @@ public class HandOfCards { ...@@ -52,23 +58,4 @@ public class HandOfCards {
(handOfCards.stream().filter(card -> card.getSuit() == 'D').count() >= 5) ? "Flush of Diamonds" : (handOfCards.stream().filter(card -> card.getSuit() == 'D').count() >= 5) ? "Flush of Diamonds" :
(handOfCards.stream().filter(card -> card.getSuit() == 'C').count() >= 5) ? "Flush of Clubs" : "No flush"; (handOfCards.stream().filter(card -> card.getSuit() == 'C').count() >= 5) ? "Flush of Clubs" : "No flush";
} }
/**
* Method to check if the player has a straight.
*
* @return the straight as a String
*/
public String checkStraight() {
int count = 0;
String straight = "No straight";
for (int i = 0; i < handOfCards.size() - 1; i++) {
if (handOfCards.get(i).getFace() == handOfCards.get(i + 1).getFace() - 1) {
count++;
}
}
if (count == 4) {
straight = "Straight";
}
return straight;
}
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment