Fxml #8

Merged
fassband merged 31 commits from fxml into main 2022-04-30 18:09:54 +02:00
3 changed files with 57 additions and 1 deletions
Showing only changes of commit e0b1616edf - Show all commits

View File

@ -10,5 +10,8 @@ public class App {
public static void main(String[] args) {
System.out.println(new App().getGreeting());
FileIO io = new FileIO();
Tournament tournament= new Tournamenttest("hello");
io.saveTournament(tournament);
}
}

View File

@ -0,0 +1,51 @@
package ch.zhaw.projekt2.turnierverwaltung;
import java.io.*;
import java.util.ArrayList;
import java.util.List;
public class FileIO {
File saveDir;
File saves;
public FileIO() {
String savePath = System.getProperty("user.dir")+File.separator+"tournierverwaltung_angrynerds";
this.saveDir = new File(savePath);
saves = new File(saveDir, "saves");
}
public void getList() {
}
public void loadTournament(Tournament tournament) {
}
public void saveTournament(Tournament tournament) {
File newSave = new File(saves, tournament.getName()+".txt");
try {
newSave.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
try {
ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(newSave));
out.writeObject(tournament);
out.close();
System.out.println("Save File" + tournament.getName()+".txt being saved to " + saves.getAbsolutePath());
} catch (IOException e) {
e.printStackTrace();
}
}
public void getTournament(String storageSpace) {
}
}

View File

@ -1,6 +1,8 @@
package ch.zhaw.projekt2.turnierverwaltung;
public abstract class Tournament {
import java.io.Serializable;
public abstract class Tournament implements Serializable {
private String name;
public Tournament(String name){