Testeksamne, og andre ting

This commit is contained in:
2025-12-03 11:33:58 +01:00
parent 7d790d8126
commit 2c91d6de4a
17 changed files with 3337 additions and 0 deletions

Binary file not shown.

Binary file not shown.

View File

@@ -9,6 +9,8 @@ import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.control.Label;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
@@ -18,7 +20,57 @@ import java.util.Random;
public class TicTacToe extends Application {
public void start(Stage primaryStage) throws Exception {
primaryStage.setTitle("Tic Tac Toe");
BorderPane borderPaneMain = new BorderPane();
Scene scene = new Scene(borderPaneMain, 490, 490);
borderPaneMain.setPadding(new Insets(20, 20,20,20));
BorderPane borderPaneTop = new BorderPane();
BorderPane borderPaneBottom = new BorderPane();
borderPaneMain.setTop(borderPaneTop);
borderPaneMain.setBottom(borderPaneBottom);
BorderPane.setAlignment(borderPaneTop, Pos.TOP_CENTER);
BorderPane.setAlignment(borderPaneBottom, Pos.BOTTOM_CENTER);
Box[] squares = new Box[9];
for (int i = 0; i < 9; i++) {
squares[i] = new Box(150, i, 9);
squares[i].rectangle.setFill(Color.WHITE);
squares[i].rectangle.setStroke(Color.BLACK);
}
borderPaneTop.setLeft(squares[0].rectangle);
BorderPane.setAlignment(squares[0].rectangle, Pos.CENTER_LEFT);
borderPaneTop.setCenter(squares[1].rectangle);
BorderPane.setAlignment(squares[1].rectangle, Pos.CENTER);
borderPaneTop.setRight(squares[2].rectangle);
BorderPane.setAlignment(squares[2].rectangle, Pos.CENTER_RIGHT);
borderPaneMain.setLeft(squares[3].rectangle);
BorderPane.setAlignment(squares[3].rectangle, Pos.CENTER_LEFT);
borderPaneMain.setCenter(squares[4].rectangle);
BorderPane.setAlignment(squares[4].rectangle, Pos.CENTER);
borderPaneMain.setRight(squares[5].rectangle);
BorderPane.setAlignment(squares[5].rectangle, Pos.CENTER_RIGHT);
borderPaneBottom.setLeft(squares[6].rectangle);
BorderPane.setAlignment(squares[6].rectangle, Pos.CENTER_LEFT);
borderPaneBottom.setCenter(squares[7].rectangle);
BorderPane.setAlignment(squares[7].rectangle, Pos.CENTER);
borderPaneBottom.setRight(squares[8].rectangle);
BorderPane.setAlignment(squares[5].rectangle, Pos.CENTER_RIGHT);
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {launch(args);}
}
class Box {
Rectangle rectangle = new Rectangle();
int shape = 0; // 0 = Empty, 1 = Cross, 2 = Circle
int num = 0;
int[] coordinates = {0,0};
public Box(int width, int num, int totalNum) {
this.rectangle = new Rectangle(width, width);
this.num = num;
this.coordinates[0] = 20 + (width * (this.num % 3));
this.coordinates[1] = 20 + (width * (this.num % 3));
}
}