You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

79 lines
1.7 KiB

package model;
import launcher.Main;
import java.io.IOException;
import java.io.Serializable;
public class DataTable implements Serializable {
private static int id = 0;
private int gameId;
private String playerName;
private int Maxscore;
private int rounds;
private double timeElapsed;
public DataTable(int levelNumber) {
id++;
this.gameId = id;
}
public DataTable() {
id++;
this.gameId = id;
this.Maxscore = 0;
this.timeElapsed = 0;
this.playerName = "";
this.rounds = 0;
//this.score=score; Calcul du score avec la difficulté !
}
//Function update
public void update(int score, String name, double time, int rounds) {
this.Maxscore = score;
this.playerName = name;
this.timeElapsed = time;
this.rounds = rounds;
}
public void saveGame() {
Main.getDatabase().getDatabaseFiles().add(this);
try {
Main.serialize();
} catch (IOException e) {
System.out.println("Cant close stream");
}
}
public double getTimeElapsed() {
System.out.println(this.timeElapsed);
return this.timeElapsed;
}
public int maxScore() {
System.out.println(this.Maxscore);
return this.Maxscore;
}
public String playerName() {
System.out.println(this.playerName);
return this.playerName;
}
public int getRounds(){
System.out.println(this.rounds);
return this.rounds;
}
public int getGameID(){
System.out.println(this.gameId);
return this.gameId;
}
public String toString() {
return this.playerName + " : " + this.Maxscore;
}
}