/home/caleb/ASDV-Java/Semester 3/Assignments/MP1_FX_CalebFontenot/src/mp1_fx_calebfontenot/TicTacToe.java |
package mp1_fx_calebfontenot;
import javafx.application.Application;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.GridPane;
import javafx.stage.Stage;
public class TicTacToe extends Application {
@Override
public void start(Stage primaryStage) throws Exception {
final String BASE_URL = "https://files.calebfontenot.com/";
Image imageX = new Image(BASE_URL + "image/x.gif");
Image imageO = new Image(BASE_URL + "image/o.gif");
GridPane pane = new GridPane();
pane.setAlignment(Pos.CENTER);
pane.setHgap(5);
pane.setVgap(5);
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
int status = (int) (Math.random() * 3);
if (status == 0) {
pane.add(new ImageView(imageX), j, i);
} else if (status == 1) {
pane.add(new ImageView(imageO), j, i);
}
}
}
Scene scene = new Scene(pane);
primaryStage.setTitle("Tic Tac Toe");
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}