diff --git a/.gradle/7.4/checksums/checksums.lock b/.gradle/7.4/checksums/checksums.lock
deleted file mode 100644
index c0e1e0c..0000000
Binary files a/.gradle/7.4/checksums/checksums.lock and /dev/null differ
diff --git a/.gradle/7.4/checksums/md5-checksums.bin b/.gradle/7.4/checksums/md5-checksums.bin
deleted file mode 100644
index 2df228d..0000000
Binary files a/.gradle/7.4/checksums/md5-checksums.bin and /dev/null differ
diff --git a/.gradle/7.4/checksums/sha1-checksums.bin b/.gradle/7.4/checksums/sha1-checksums.bin
deleted file mode 100644
index 1bc5c79..0000000
Binary files a/.gradle/7.4/checksums/sha1-checksums.bin and /dev/null differ
diff --git a/.gradle/7.4/dependencies-accessors/dependencies-accessors.lock b/.gradle/7.4/dependencies-accessors/dependencies-accessors.lock
deleted file mode 100644
index 5a44c73..0000000
Binary files a/.gradle/7.4/dependencies-accessors/dependencies-accessors.lock and /dev/null differ
diff --git a/.gradle/7.4/fileChanges/last-build.bin b/.gradle/7.4/fileChanges/last-build.bin
deleted file mode 100644
index f76dd23..0000000
Binary files a/.gradle/7.4/fileChanges/last-build.bin and /dev/null differ
diff --git a/.gradle/7.4/fileHashes/fileHashes.lock b/.gradle/7.4/fileHashes/fileHashes.lock
deleted file mode 100644
index 00ae177..0000000
Binary files a/.gradle/7.4/fileHashes/fileHashes.lock and /dev/null differ
diff --git a/.gradle/7.4/gc.properties b/.gradle/7.4/gc.properties
deleted file mode 100644
index e69de29..0000000
diff --git a/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/.gradle/buildOutputCleanup/buildOutputCleanup.lock
deleted file mode 100644
index 0041aac..0000000
Binary files a/.gradle/buildOutputCleanup/buildOutputCleanup.lock and /dev/null differ
diff --git a/.gradle/buildOutputCleanup/cache.properties b/.gradle/buildOutputCleanup/cache.properties
deleted file mode 100644
index 07b3692..0000000
--- a/.gradle/buildOutputCleanup/cache.properties
+++ /dev/null
@@ -1,2 +0,0 @@
-#Mon Apr 25 20:06:35 CEST 2022
-gradle.version=7.4
diff --git a/.gradle/vcs-1/gc.properties b/.gradle/vcs-1/gc.properties
deleted file mode 100644
index e69de29..0000000
diff --git a/.idea/.gitignore b/.idea/.gitignore
deleted file mode 100644
index 73f69e0..0000000
--- a/.idea/.gitignore
+++ /dev/null
@@ -1,8 +0,0 @@
-# Default ignored files
-/shelf/
-/workspace.xml
-# Datasource local storage ignored files
-/dataSources/
-/dataSources.local.xml
-# Editor-based HTTP Client requests
-/httpRequests/
diff --git a/.idea/.name b/.idea/.name
deleted file mode 100644
index 1b960e6..0000000
--- a/.idea/.name
+++ /dev/null
@@ -1 +0,0 @@
-turnierverwaltung
\ No newline at end of file
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
deleted file mode 100644
index b73660a..0000000
--- a/.idea/compiler.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/gradle.xml b/.idea/gradle.xml
deleted file mode 100644
index ccf41b5..0000000
--- a/.idea/gradle.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml
deleted file mode 100644
index fdc392f..0000000
--- a/.idea/jarRepositories.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries-with-intellij-classes.xml b/.idea/libraries-with-intellij-classes.xml
deleted file mode 100644
index 9fa3156..0000000
--- a/.idea/libraries-with-intellij-classes.xml
+++ /dev/null
@@ -1,65 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
deleted file mode 100644
index f09f125..0000000
--- a/.idea/misc.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
deleted file mode 100644
index 35eb1dd..0000000
--- a/.idea/vcs.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/build.gradle b/app/build.gradle
index 24699f1..dfbf65f 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -9,6 +9,12 @@
plugins {
// Apply the application plugin to add support for building a CLI application in Java.
id 'application'
+ id 'org.openjfx.javafxplugin' version '0.0.12'
+}
+
+javafx {
+ version = '17.0.1'
+ modules = [ 'javafx.controls', 'javafx.fxml' ]
}
repositories {
@@ -22,6 +28,8 @@ dependencies {
// This dependency is used by the application.
implementation 'com.google.guava:guava:30.1.1-jre'
+
+
}
application {
diff --git a/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/App.java b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/App.java
index e06a54c..2099098 100644
--- a/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/App.java
+++ b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/App.java
@@ -3,12 +3,11 @@
*/
package ch.zhaw.projekt2.turnierverwaltung;
-public class App {
- public String getGreeting() {
- return "Hello World!";
- }
+import ch.zhaw.projekt2.turnierverwaltung.main.MainWindow;
+import javafx.application.Application;
+public class App {
public static void main(String[] args) {
- System.out.println(new App().getGreeting());
+ Application.launch(MainWindow.class,args);
}
}
diff --git a/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/FXController.java b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/FXController.java
new file mode 100644
index 0000000..2e51f0d
--- /dev/null
+++ b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/FXController.java
@@ -0,0 +1,35 @@
+package ch.zhaw.projekt2.turnierverwaltung;
+
+import javafx.scene.layout.Pane;
+
+public abstract class FXController {
+ Tournament tournament;
+ Factory factory;
+ FileIO fileIO;
+ Pane pane;
+
+ public void setup(Tournament tournament, FileIO fileIO, Factory factory, Pane pane){
+ this.tournament = tournament;
+ this.fileIO = fileIO;
+ this.factory = factory;
+ this.pane = pane;
+ }
+
+ public abstract void loadContent();
+
+ protected Tournament getTournament() {
+ return tournament;
+ }
+
+ protected FileIO getFileIO() {
+ return fileIO;
+ }
+
+ protected Factory getFactory() {
+ return factory;
+ }
+
+ protected Pane getPane() {
+ return pane;
+ }
+}
diff --git a/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/Factory.java b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/Factory.java
new file mode 100644
index 0000000..06ca006
--- /dev/null
+++ b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/Factory.java
@@ -0,0 +1,65 @@
+package ch.zhaw.projekt2.turnierverwaltung;
+
+import ch.zhaw.projekt2.turnierverwaltung.main.tournamentList.TournamentListController;
+import javafx.fxml.FXMLLoader;
+import javafx.scene.layout.BorderPane;
+
+import java.io.IOException;
+import java.net.URL;
+
+public class Factory {
+ private Tournament tournament;
+ private FileIO fileIO;
+
+ public Factory(FileIO fileIO){
+ this.fileIO = fileIO;
+ }
+
+ public Tournament getTournament() {
+ return tournament;
+ }
+
+ public void setTournament(Tournament tournament) {
+ this.tournament = tournament;
+ }
+
+ public BorderPane loadMainWindow(){
+ FXMLLoader loader = new FXMLLoader(getClass().getResource("mainWindow.fxml"));
+ try {
+ return loader.load();
+ } catch (IOException e) {
+ e.printStackTrace();
+ //TODO handle and logging
+ }
+ return null;
+ }
+
+ public void loadTournamentList(BorderPane pane){
+ TournamentListController controller = (TournamentListController) setCenterOfBorderPane(pane, getClass().getResource("tournamentList/tournamentList.fxml"));
+ }
+
+ //Can be used to Open new Scene in same Stage.
+ //This way possible to later give object to Controller
+ public void loadParticipantFormular(BorderPane pane) {
+ setCenterOfBorderPane(pane, getClass().getResource("participantAddFormular/participantFormular.fxml"));
+ }
+
+ private FXController setCenterOfBorderPane(BorderPane pane, URL location) {
+ FXController controller = null;
+ try {
+ FXMLLoader loader = new FXMLLoader(location);
+ pane.setCenter(loader.load());
+ controller = loader.getController();
+ controller.setup(tournament, fileIO, this, pane);
+ controller.loadContent();
+ } catch (IOException e) {
+ e.printStackTrace();
+ //TODO handle and logging?
+ }
+ return controller;
+ }
+
+
+
+
+}
diff --git a/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/FileIO.java b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/FileIO.java
new file mode 100644
index 0000000..9b9365d
--- /dev/null
+++ b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/FileIO.java
@@ -0,0 +1,132 @@
+package ch.zhaw.projekt2.turnierverwaltung;
+
+
+import java.io.*;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.logging.Logger;
+
+
+public class FileIO {
+ private File mainDir;
+ private File saves;
+
+ private static final Logger logger = Logger.getLogger(FileIO.class.getName());
+
+
+ public FileIO(String saveLocation) {
+ this.mainDir = new File(saveLocation);
+ if (!mainDir.exists()) {
+ logger.fine("Creating main directory in given path" + saveLocation);
+ mainDir.mkdir();
+ } else {
+ logger.finer("main directory already exists");
+ }
+
+ saves = new File(mainDir, "saves");
+ if (!saves.exists()) {
+ saves.mkdir();
+ logger.fine("Creating save directory");
+ } else {
+ logger.finer("save directory already exists");
+ }
+ }
+
+ public List getList() {
+ logger.fine("Creating a List out of all Files in the save directory and returning it");
+ List tournaments = new ArrayList<>();
+ for(File tournament : saves.listFiles()){
+ tournaments.add(new TournamentFile(tournament.toURI()));
+ }
+ return tournaments;
+ }
+
+ /**
+ * @param tournamentFile
+ * @return
+ * @throws ClassNotFoundException
+ * @throws IOException File not found or not readable.
+ */
+ public Tournament loadTournament(File tournamentFile) throws IOException, ClassNotFoundException {
+ if (tournamentFile == null) {
+ logger.warning("Given tournament file is empty");
+ throw new IllegalArgumentException("Tournament File is null");
+ }
+ Tournament tournament;
+ logger.finer("Starting up Input Stream to read File");
+ ObjectInputStream in = null;
+ try {
+ logger.fine("Setting up input file and reading it");
+ FileInputStream fileInputStream = new FileInputStream(tournamentFile);
+ in = new ObjectInputStream(fileInputStream);
+ logger.finer("Starting to read tournament File");
+ tournament = (Tournament) in.readObject();
+ } catch (FileNotFoundException e) {
+ logger.severe("Could not find tournament File");
+ throw e;
+ } catch (IOException e) {
+ logger.severe("Failed to read File" + tournamentFile.getName());
+ throw new IOException("Error while reading File",e);
+ } catch (ClassNotFoundException e) {
+ logger.severe("No definition for the class with the specified name could be found");
+ throw new ClassNotFoundException("No definition for the class with the specified name could be found",e);
+ } finally {
+ if (in != null) {
+ try {
+ logger.finer("Trying to close input stream");
+ in.close();
+ } catch (IOException e) {
+ logger.severe("Failed to close input stream");
+ throw new IOException("Error while closing input stream",e);
+ }
+ }
+ }
+ return tournament;
+ }
+
+ public void saveTournament(Tournament tournament) {
+ if (tournament == null) {
+ logger.warning("Given tournament file is empty");
+ throw new IllegalArgumentException("Null tournament received");
+ }
+ File newSave = new File(saves, tournament.getName() + ".txt");
+ ObjectOutputStream out = null;
+
+ try {
+ newSave.createNewFile();
+ out = new ObjectOutputStream(new FileOutputStream(newSave));
+ out.writeObject(tournament);
+ System.out.println("Save File" + tournament.getName() + ".txt being saved to " + saves.getAbsolutePath());
+
+ } catch (FileNotFoundException e) {
+ throw new RuntimeException(e);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ } finally {
+ if (out != null) {
+ try {
+ out.close();
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ }
+
+ }
+
+ public class TournamentFile extends File{
+
+ public TournamentFile(URI uri) {
+ super(uri);
+ }
+
+ public String toString(){
+ String name = getName();
+ return name.split("\\.")[0];
+ }
+
+ }
+}
diff --git a/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/Tournament.java b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/Tournament.java
index 5845a12..0da286d 100644
--- a/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/Tournament.java
+++ b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/Tournament.java
@@ -1,6 +1,8 @@
package ch.zhaw.projekt2.turnierverwaltung;
-public class Tournament {
+import java.io.Serializable;
+
+public class Tournament implements Serializable {
private String name;
public Tournament(String name){
diff --git a/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/main/MainWindow.java b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/main/MainWindow.java
new file mode 100644
index 0000000..4602c5d
--- /dev/null
+++ b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/main/MainWindow.java
@@ -0,0 +1,35 @@
+package ch.zhaw.projekt2.turnierverwaltung.main;
+
+import ch.zhaw.projekt2.turnierverwaltung.Factory;
+import ch.zhaw.projekt2.turnierverwaltung.FileIO;
+import javafx.application.Application;
+import javafx.fxml.FXMLLoader;
+import javafx.scene.Scene;
+import javafx.scene.layout.BorderPane;
+import javafx.scene.layout.Pane;
+import javafx.stage.Stage;
+
+import java.awt.*;
+import java.io.IOException;
+
+public class MainWindow extends Application {
+ private FileIO fileIO = new FileIO(System.getProperty("user.dir") + "/tournierverwaltung_angrynerds");
+ private Factory factory = new Factory(fileIO); //TODO make it private!
+
+ @Override
+ public void start(Stage primaryStage) throws Exception {
+
+ BorderPane pane = factory.loadMainWindow();
+ factory.loadTournamentList(pane);
+
+
+ Scene scene = new Scene(pane);
+ primaryStage.setScene(scene);
+ primaryStage.setMaximized(true);
+ primaryStage.setResizable(false);
+ primaryStage.setFullScreen(false);
+ primaryStage.show();
+ }
+
+
+}
diff --git a/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/main/MainWindowController.java b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/main/MainWindowController.java
new file mode 100644
index 0000000..ef5e1d6
--- /dev/null
+++ b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/main/MainWindowController.java
@@ -0,0 +1,23 @@
+package ch.zhaw.projekt2.turnierverwaltung.main;
+
+import ch.zhaw.projekt2.turnierverwaltung.FXController;
+import javafx.event.ActionEvent;
+import javafx.fxml.FXML;
+
+public class MainWindowController extends FXController {
+
+ @FXML
+ void changeLangToGerman(ActionEvent event) {
+
+ }
+
+ @FXML
+ void closeApplication(ActionEvent event) {
+
+ }
+
+ @Override
+ public void loadContent() {
+
+ }
+}
diff --git a/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/main/participantAddFormular/participantFormularController.java b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/main/participantAddFormular/participantFormularController.java
new file mode 100644
index 0000000..08877c1
--- /dev/null
+++ b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/main/participantAddFormular/participantFormularController.java
@@ -0,0 +1,83 @@
+package ch.zhaw.projekt2.turnierverwaltung.main.participantAddFormular;
+
+import ch.zhaw.projekt2.turnierverwaltung.FXController;
+import javafx.event.ActionEvent;
+import javafx.fxml.FXML;
+import javafx.scene.control.Button;
+import javafx.scene.control.Label;
+import javafx.scene.control.ListView;
+import javafx.scene.control.TextField;
+import javafx.scene.input.MouseEvent;
+import javafx.scene.layout.GridPane;
+import javafx.scene.layout.VBox;
+
+public class ParticipantFormularController extends FXController {
+
+ @FXML
+ private Button addBtn;
+
+ @FXML
+ private Label birthDateLabel;
+
+ @FXML
+ private TextField birthDateTextField;
+
+ @FXML
+ private VBox changeBtn;
+
+ @FXML
+ private Label firstNameLabel;
+
+ @FXML
+ private TextField firstNameTextField;
+
+ @FXML
+ private GridPane grid;
+
+ @FXML
+ private Label newParticipantFormularTitle;
+
+ @FXML
+ private Button openBtn;
+
+ @FXML
+ private Label participantListTitle;
+
+ @FXML
+ private ListView> participantListView;
+
+ @FXML
+ private Label participantNameLabel;
+
+ @FXML
+ private TextField participantNameTextField;
+
+ @FXML
+ private Label phoneNumberLabel;
+
+ @FXML
+ private TextField phoneNumberTextField;
+
+ @FXML
+ private Button saveBtn;
+
+ @FXML
+ void addParticipant(ActionEvent event) {
+
+ }
+
+ @FXML
+ void changeParticipant(MouseEvent event) {
+
+ }
+
+ @FXML
+ void save(ActionEvent event) {
+
+ }
+
+ @Override
+ public void loadContent() {
+
+ }
+}
diff --git a/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/main/tournamentList/tournamentListController.java b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/main/tournamentList/tournamentListController.java
new file mode 100644
index 0000000..37c5c7b
--- /dev/null
+++ b/app/src/main/java/ch/zhaw/projekt2/turnierverwaltung/main/tournamentList/tournamentListController.java
@@ -0,0 +1,79 @@
+package ch.zhaw.projekt2.turnierverwaltung.main.tournamentList;
+
+import ch.zhaw.projekt2.turnierverwaltung.FXController;
+import ch.zhaw.projekt2.turnierverwaltung.Factory;
+import ch.zhaw.projekt2.turnierverwaltung.FileIO;
+import ch.zhaw.projekt2.turnierverwaltung.Tournament;
+import ch.zhaw.projekt2.turnierverwaltung.main.MainWindow;
+import javafx.beans.Observable;
+import javafx.collections.FXCollections;
+import javafx.collections.ObservableList;
+import javafx.event.ActionEvent;
+import javafx.fxml.FXML;
+import javafx.scene.control.Button;
+import javafx.scene.control.ChoiceBox;
+import javafx.scene.control.Label;
+import javafx.scene.control.ListView;
+import javafx.scene.layout.BorderPane;
+import javafx.scene.layout.GridPane;
+
+import java.io.File;
+import java.io.IOException;
+
+public class TournamentListController extends FXController {
+
+ @FXML
+ private Button createBtn;
+
+ @FXML
+ private GridPane grid;
+
+ @FXML
+ private ChoiceBox> modusChoiceBox;
+
+ @FXML
+ private Label newTournamentFormularTitle;
+
+ @FXML
+ private Button openBtn;
+
+ @FXML
+ private Label tournierListTitle;
+
+ @FXML
+ private ListView tournierListView;
+
+ @FXML
+ private Label tournierModLabel;
+
+ @FXML
+ private Label turnierNameLabel;
+
+ @FXML
+ void createTournament(ActionEvent event) {
+
+ }
+
+ @FXML
+ void openTournament(ActionEvent event) {
+ try {
+ File tournamentFile = tournierListView.getSelectionModel().getSelectedItems().get(0);
+ getFactory().setTournament(getFileIO().loadTournament(tournamentFile));
+ getFactory().loadParticipantFormular((BorderPane) getPane());
+ } catch (IOException e) {
+ e.printStackTrace();
+ } catch (ClassNotFoundException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void loadContent() {
+ ObservableList tournamentFiles = FXCollections.observableArrayList();
+ for(File tournament : getFileIO().getList()){
+ tournamentFiles.add(tournament);
+ }
+ tournierListView.setItems(tournamentFiles);
+ }
+}
+
diff --git a/app/src/main/resources/ch/zhaw/projekt2/turnierverwaltung/MainWindow.fxml b/app/src/main/resources/ch/zhaw/projekt2/turnierverwaltung/MainWindow.fxml
new file mode 100644
index 0000000..af04e72
--- /dev/null
+++ b/app/src/main/resources/ch/zhaw/projekt2/turnierverwaltung/MainWindow.fxml
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/resources/ch/zhaw/projekt2/turnierverwaltung/Style.css b/app/src/main/resources/ch/zhaw/projekt2/turnierverwaltung/Style.css
new file mode 100644
index 0000000..d69b698
--- /dev/null
+++ b/app/src/main/resources/ch/zhaw/projekt2/turnierverwaltung/Style.css
@@ -0,0 +1,10 @@
+#mainContainer {
+ -fx-min-height: 100%;
+ -fx-min-width: 100%;
+ -fx-background-color: #f8f8f8;
+
+}
+
+/*
+Formular Right Side
+ */
diff --git a/app/src/main/resources/ch/zhaw/projekt2/turnierverwaltung/participantAddFormular/participantFormular.fxml b/app/src/main/resources/ch/zhaw/projekt2/turnierverwaltung/participantAddFormular/participantFormular.fxml
new file mode 100644
index 0000000..caa919e
--- /dev/null
+++ b/app/src/main/resources/ch/zhaw/projekt2/turnierverwaltung/participantAddFormular/participantFormular.fxml
@@ -0,0 +1,114 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/resources/ch/zhaw/projekt2/turnierverwaltung/tournamentList/tournamentList.fxml b/app/src/main/resources/ch/zhaw/projekt2/turnierverwaltung/tournamentList/tournamentList.fxml
new file mode 100644
index 0000000..74c2bf2
--- /dev/null
+++ b/app/src/main/resources/ch/zhaw/projekt2/turnierverwaltung/tournamentList/tournamentList.fxml
@@ -0,0 +1,100 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/test/java/ch/zhaw/projekt2/turnierverwaltung/AppTest.java b/app/src/test/java/ch/zhaw/projekt2/turnierverwaltung/AppTest.java
deleted file mode 100644
index 252063c..0000000
--- a/app/src/test/java/ch/zhaw/projekt2/turnierverwaltung/AppTest.java
+++ /dev/null
@@ -1,14 +0,0 @@
-/*
- * This Java source file was generated by the Gradle 'init' task.
- */
-package ch.zhaw.projekt2.turnierverwaltung;
-
-import org.junit.jupiter.api.Test;
-import static org.junit.jupiter.api.Assertions.*;
-
-class AppTest {
- @Test void appHasAGreeting() {
- App classUnderTest = new App();
- assertNotNull(classUnderTest.getGreeting(), "app should have a greeting");
- }
-}
diff --git a/app/src/test/java/ch/zhaw/projekt2/turnierverwaltung/FileIOTest.java b/app/src/test/java/ch/zhaw/projekt2/turnierverwaltung/FileIOTest.java
new file mode 100644
index 0000000..fd68e22
--- /dev/null
+++ b/app/src/test/java/ch/zhaw/projekt2/turnierverwaltung/FileIOTest.java
@@ -0,0 +1,127 @@
+package ch.zhaw.projekt2.turnierverwaltung;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Nested;
+import org.junit.jupiter.api.Test;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Comparator;
+import java.util.List;
+import java.util.logging.Logger;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+class FileIOTest {
+
+ String RESOURCES_DIR = "./src/test/resources/ch/zhaw/projekt2/turnierverwaltung/";
+ String mainDir;
+ String saveDir;
+ FileIO io;
+
+ @Test
+ void FileIONewDir() throws IOException {
+ mainDir = RESOURCES_DIR + "FileIONew";
+ saveDir = mainDir + "/saves";
+ File mainDirFile = new File(mainDir);
+ File saveDirFile = new File(mainDir);
+ try{
+ Files.walk(mainDirFile.toPath())
+ .sorted(Comparator.reverseOrder())
+ .map(Path::toFile)
+ .forEach(File::delete);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ assertFalse(mainDirFile.exists());
+ assertFalse(saveDirFile.exists());
+ io = new FileIO(mainDir);
+ assertTrue(mainDirFile.exists());
+ assertTrue(saveDirFile.exists());
+ Files.walk(mainDirFile.toPath())
+ .sorted(Comparator.reverseOrder())
+ .map(Path::toFile)
+ .forEach(File::delete);
+ assertFalse(mainDirFile.exists());
+ assertFalse(saveDirFile.exists());
+ }
+
+ @Nested
+ class Read{
+ @BeforeEach
+ void init() {
+ mainDir = RESOURCES_DIR + "FileIORead";
+ io = new FileIO(mainDir);
+ }
+
+ @Test
+ void getList() {
+ List tournaments = io.getList();
+ assertEquals("empty.txt", tournaments.get(0).getName());
+ assertEquals("test1.txt", tournaments.get(1).getName());
+ }
+
+ @Test
+ void getListEmpty() {
+ mainDir = RESOURCES_DIR + "FileIOEmpty";
+ io = new FileIO(mainDir);
+ assertEquals(0, io.getList().size());
+ }
+
+ @Test
+ void loadTournament() throws IOException, ClassNotFoundException {
+ mainDir = RESOURCES_DIR + "FileIORead";
+ io = new FileIO(mainDir);
+ Tournament tournament = io.loadTournament(new File(mainDir + "/saves/test1.txt"));
+ assertEquals("test1", tournament.getName());
+ }
+
+ @Test
+ void loadTournamentNotExisting(){
+ io = new FileIO(mainDir);
+ assertThrows(FileNotFoundException.class, () -> io.loadTournament(new File("Not-existing-File")));
+ }
+
+ @Test
+ void loadTournamentEmpty(){
+ io = new FileIO(mainDir);
+ assertThrows(IOException.class, () -> io.loadTournament(new File(mainDir + "/saves/empty.txt")));
+ }
+
+ @Test
+ void loadTournamentFileNull(){
+ io = new FileIO(mainDir);
+ assertThrows(IllegalArgumentException.class, () -> io.loadTournament(null));
+ }
+ }
+
+ @Nested
+ class Save{
+ @BeforeEach
+ void setup(){
+ mainDir = RESOURCES_DIR + "FileIOSave";
+ io = new FileIO(mainDir);
+ }
+
+ @Test
+ void saveTournament() throws IOException {
+ Tournament tournament = new Tournament("test1");
+ io.saveTournament(tournament);
+ File file = new File(mainDir + "/saves/test1.txt");
+ if(file.exists()){
+ file.delete();
+ } else {
+ fail();
+ }
+ }
+
+ @Test
+ void saveTournamentNull(){
+ assertThrows(IllegalArgumentException.class, () -> io.saveTournament(null));
+ }
+ }
+}
\ No newline at end of file
diff --git a/.gradle/7.4/dependencies-accessors/gc.properties b/app/src/test/resources/ch/zhaw/projekt2/turnierverwaltung/FileIORead/saves/empty.txt
similarity index 100%
rename from .gradle/7.4/dependencies-accessors/gc.properties
rename to app/src/test/resources/ch/zhaw/projekt2/turnierverwaltung/FileIORead/saves/empty.txt
diff --git a/app/src/test/resources/ch/zhaw/projekt2/turnierverwaltung/FileIORead/saves/test1.txt b/app/src/test/resources/ch/zhaw/projekt2/turnierverwaltung/FileIORead/saves/test1.txt
new file mode 100644
index 0000000..1053e93
Binary files /dev/null and b/app/src/test/resources/ch/zhaw/projekt2/turnierverwaltung/FileIORead/saves/test1.txt differ