資源簡介
Java語言程序設計與數據結構(基礎篇)第15章課后習題代碼

代碼片段和文件信息
import?javafx.application.Application;
import?javafx.geometry.Pos;
import?javafx.scene.Scene;
import?javafx.scene.control.Button;
import?javafx.scene.image.ImageView;
import?javafx.scene.layout.BorderPane;
import?javafx.scene.layout.HBox;
import?javafx.stage.Stage;
import?java.util.ArrayList;
public?class?Exercise15_01?extends?Application?{
??@Override
??//?Override?the?start?method?in?the?Application?class
??public?void?start(Stage?primaryStage)?{
????//?There?are?two?ways?for?shuffling.?One?is?to?use?the?hint?in?the?book.?
????//?The?other?way?is?to?use?the?static?shuffle?method?in?the?java.util.Collections?class.
????ArrayList?list?=?new?ArrayList<>();
????for?(int?i?=?1;?i?<=?52;?i++)?{
??????list.add(i);
????}
????java.util.Collections.shuffle(list);
????
????HBox?hBox?=?new?HBox(5);
????hBox.setAlignment(Pos.CENTER);
????hBox.getChildren().add(new?ImageView(“image/card/“?+?list.get(0)?+?“.png“));
????hBox.getChildren().add(new?ImageView(“image/card/“?+?list.get(1)?+?“.png“));
????hBox.getChildren().add(new?ImageView(“image/card/“?+?list.get(2)?+?“.png“));
????hBox.getChildren().add(new?ImageView(“image/card/“?+?list.get(3)?+?“.png“));
????
????//?Create?a?button
????Button?btRefresh?=?new?Button(“Refresh“);
????btRefresh.setOnAction(e?->?{
??????java.util.Collections.shuffle(list);
??????hBox.getChildren().clear();
??????hBox.getChildren().add(new?ImageView(“image/card/“?+?list.get(0)?+?“.png“));
??????hBox.getChildren().add(new?ImageView(“image/card/“?+?list.get(1)?+?“.png“));
??????hBox.getChildren().add(new?ImageView(“image/card/“?+?list.get(2)?+?“.png“));
??????hBox.getChildren().add(new?ImageView(“image/card/“?+?list.get(3)?+?“.png“));
????});
???
????BorderPane?pane?=?new?BorderPane();
????pane.setCenter(hBox);
????pane.setBottom(btRefresh);
????BorderPane.setAlignment(btRefresh?Pos.TOP_CENTER);
????//?Create?a?scene?and?place?it?in?the?stage
????Scene?scene?=?new?Scene(pane?250?150);
????primaryStage.settitle(“Exercise15_01“);?//?Set?the?stage?title
????primaryStage.setScene(scene);?//?Place?the?scene?in?the?stage
????primaryStage.show();?//?Display?the?stage
??}
??
??/**
???*?The?main?method?is?only?needed?for?the?IDE?with?limited
???*?JavaFX?support.?Not?needed?for?running?from?the?command?line.
???*/
??public?static?void?main(String[]?args)?{
????launch(args);
??}
}?
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????867??2019-07-04?20:00??chapter15\chapter29\Exercise29_03.java
?????文件???????2592??2019-07-04?20:00??chapter15\chapter29\Exercise29_04(1).java
?????文件???????2592??2019-07-04?20:00??chapter15\chapter29\Exercise29_04.java
?????文件???????2274??2019-07-04?20:00??chapter15\chapter29\Exercise29_05.java
?????文件???????1544??2019-07-04?20:00??chapter15\chapter29\Exercise29_09.java
?????文件???????1900??2019-07-04?20:00??chapter15\chapter29\Exercise29_10.java
?????文件???????1612??2019-07-04?20:00??chapter15\chapter29\Exercise29_11.java
?????文件???????4128??2019-07-04?20:00??chapter15\chapter29\Exercise29_12.java
?????文件???????6167??2019-07-04?20:00??chapter15\chapter29\Exercise29_13.java
?????文件???????6664??2019-07-04?20:00??chapter15\chapter29\Exercise29_14.java
?????文件???????8446??2019-07-04?20:00??chapter15\chapter29\Exercise29_15.java
?????文件???????7480??2019-07-04?20:00??chapter15\chapter29\Exercise29_16.java
?????文件??????13770??2019-07-04?20:00??chapter15\chapter29\Exercise29_17.java
?????文件??????24181??2019-07-04?20:00??chapter15\chapter29\Exercise29_18.java
?????文件??????21827??2019-07-04?20:00??chapter15\chapter29\Exercise29_20.java
?????文件???????2398??2019-07-04?20:00??chapter15\Exercise15_01(1).java
?????文件???????2103??2019-07-04?20:00??chapter15\Exercise15_01Extra.java
?????文件???????1575??2019-07-04?20:00??chapter15\Exercise15_02.java
?????文件???????2784??2019-07-04?20:00??chapter15\Exercise15_02Extra.java
?????文件???????2225??2019-07-04?20:00??chapter15\Exercise15_03.java
?????文件???????1467??2019-07-04?20:00??chapter15\Exercise15_03Extra.java
?????文件???????2677??2019-07-04?20:00??chapter15\Exercise15_04.java
?????文件???????2729??2019-07-04?20:00??chapter15\Exercise15_04Extra.java
?????文件???????2900??2019-07-04?20:00??chapter15\Exercise15_05.java
?????文件???????8387??2019-07-04?20:00??chapter15\Exercise15_05Extra.java
?????文件???????1172??2019-07-04?20:00??chapter15\Exercise15_06.java
?????文件???????3363??2019-07-04?20:00??chapter15\Exercise15_06Extra.java
?????文件???????1211??2019-07-04?20:00??chapter15\Exercise15_07.java
?????文件???????5885??2019-07-04?20:00??chapter15\Exercise15_07Extra.java
?????文件???????1170??2019-07-04?20:00??chapter15\Exercise15_08.java
............此處省略37個文件信息
- 上一篇:Louvain java實現
- 下一篇:java實現聊天的服務端
評論
共有 條評論