我已经尝试过不使用类使用局部变量相同的问题。
GUI应该打开,我可以提交我想要的牌的数量,并将从一副牌中随机选择。和 GUI 上的其他按钮也
public class MainGUI extends Application {
public void start(Stage primaryStage) {
class deck {
public ArrayList <Integer> Deck;
public ArrayList<Integer> shuffleDeck(ArrayList<Integer> Deck) {
int x = 52;
for (int i = 1; i <= x; ++i ) {
Deck.add(i);
}
Collections.shuffle(Deck);
return Deck;
}
public ArrayList<Integer> randomCardsSelector(int x, ArrayList<Integer> Deck){
ArrayList<Integer> selectedCards = new ArrayList<Integer>();
Random rand = new Random();
for(int i = 1; i <= x; ++i) {
int newElement = rand.nextInt(Deck.size());
selectedCards.add(Deck.get(newElement));
Deck.remove(newElement);
}
return selectedCards;
}
}
//Horizontal box containing Label, TextField, Button, Cards drawn
HBox topContainer = new HBox();
topContainer.setSpacing(10);
topContainer.setPadding(new Insets(25,50,25,50));
//This is the label
Label insertNbr = new Label();
insertNbr.setText("Number of cards:");
insertNbr.setPadding(new Insets(5,5,5,5));
//This the TextField
TextField cardNbr = new TextField();
cardNbr.setPadding(new Insets(5,5,5,5));
cardNbr.setPrefWidth(30);
//This is the submit button
Button submitBtn = new Button();
submitBtn.setPadding(new Insets(5,5,5,5));
submitBtn.setText("Submit");
HBox newBox = new HBox();
//This is the fetch button
Button fetchBtn = new Button();
fetchBtn.setPadding(new Insets(5,5,5,5));
fetchBtn.setText("Fetch");
fetchBtn.setDisable(true);
});
我已经尝试过不使用类使用局部变量相同的问题。
冉冉说
相关分类