2022-03-07 15:38:35 +01:00
|
|
|
public class User {
|
2022-02-10 11:12:17 +01:00
|
|
|
|
2022-02-20 17:44:44 +01:00
|
|
|
private String name = "default";
|
|
|
|
|
2022-02-10 11:12:17 +01:00
|
|
|
/**
|
2022-03-07 15:38:35 +01:00
|
|
|
* Konstruktor für Objekte der Klasse User
|
2022-02-10 11:12:17 +01:00
|
|
|
*/
|
2022-02-20 17:44:44 +01:00
|
|
|
public User(String name)
|
2022-02-10 11:12:17 +01:00
|
|
|
{
|
2022-02-20 17:44:44 +01:00
|
|
|
setName(name);
|
2022-02-10 11:12:17 +01:00
|
|
|
}
|
|
|
|
|
2022-02-20 17:44:44 +01:00
|
|
|
|
2022-03-02 13:25:21 +01:00
|
|
|
|
2022-02-20 17:44:44 +01:00
|
|
|
public void setPassword(String password)
|
2022-02-10 11:12:17 +01:00
|
|
|
{
|
2022-03-07 15:38:35 +01:00
|
|
|
Game.databaseConnector.executeStatement("UPDATE User SET password = " + password + " Where name = " + this.name);
|
2022-02-10 11:12:17 +01:00
|
|
|
}
|
2022-02-20 17:44:44 +01:00
|
|
|
|
2022-03-02 13:25:21 +01:00
|
|
|
|
2022-02-10 11:12:17 +01:00
|
|
|
public String getPassword()
|
|
|
|
{
|
2022-03-07 15:38:35 +01:00
|
|
|
Game.databaseConnector.executeStatement("SELECT password FROM User Where name =" + this.name);
|
|
|
|
String result = Game.databaseConnector.getCurrentQueryResult().getData()[0][0];
|
2022-02-20 17:44:44 +01:00
|
|
|
return result;
|
2022-02-10 11:12:17 +01:00
|
|
|
}
|
2022-02-20 17:44:44 +01:00
|
|
|
|
|
|
|
|
2022-03-02 13:25:21 +01:00
|
|
|
|
2022-02-10 11:35:59 +01:00
|
|
|
public void setName(String name)
|
2022-02-10 11:12:17 +01:00
|
|
|
{
|
2022-03-07 15:38:35 +01:00
|
|
|
Game.databaseConnector.executeStatement("UPDATE User SET name = " + name + " Where name = " + this.name);
|
2022-02-10 11:12:17 +01:00
|
|
|
}
|
|
|
|
|
2022-03-02 13:25:21 +01:00
|
|
|
|
2022-02-10 11:12:17 +01:00
|
|
|
public String getName()
|
|
|
|
{
|
2022-02-20 17:44:44 +01:00
|
|
|
return name;
|
2022-02-14 09:29:56 +01:00
|
|
|
}
|
2022-02-10 11:12:17 +01:00
|
|
|
|
|
|
|
|
2022-03-02 13:25:21 +01:00
|
|
|
|
2022-02-20 17:44:44 +01:00
|
|
|
public void setWinPercentage(float winPercentage)
|
2022-02-10 11:12:17 +01:00
|
|
|
{
|
2022-03-07 15:38:35 +01:00
|
|
|
Game.databaseConnector.executeStatement("UPDATE User SET winPercentage = " + winPercentage + " Where name = " + this.name);
|
2022-02-20 17:44:44 +01:00
|
|
|
}
|
2022-02-10 11:35:59 +01:00
|
|
|
|
2022-03-02 13:25:21 +01:00
|
|
|
|
2022-02-20 17:44:44 +01:00
|
|
|
public float getWinPercentage()
|
2022-02-14 09:29:56 +01:00
|
|
|
{
|
2022-03-07 15:38:35 +01:00
|
|
|
Game.databaseConnector.executeStatement("SELECT winPercentage FROM User Where name =" + this.name);
|
|
|
|
String result = Game.databaseConnector.getCurrentQueryResult().getData()[0][0];
|
2022-02-20 17:44:44 +01:00
|
|
|
return Float.parseFloat(result);
|
2022-02-14 09:29:56 +01:00
|
|
|
}
|
|
|
|
|
2022-02-20 17:44:44 +01:00
|
|
|
|
2022-03-02 13:25:21 +01:00
|
|
|
|
2022-02-20 17:44:44 +01:00
|
|
|
public void setTimesPlayed(int timesPlayed)
|
2022-02-10 11:35:59 +01:00
|
|
|
{
|
2022-03-07 15:38:35 +01:00
|
|
|
Game.databaseConnector.executeStatement("UPDATE User SET timesPlayed = " + timesPlayed + " Where name = " + this.name);
|
2022-02-10 11:35:59 +01:00
|
|
|
}
|
|
|
|
|
2022-03-02 13:25:21 +01:00
|
|
|
|
2022-02-20 17:44:44 +01:00
|
|
|
public int getTimesPlayed()
|
2022-02-10 11:35:59 +01:00
|
|
|
{
|
2022-03-07 15:38:35 +01:00
|
|
|
Game.databaseConnector.executeStatement("SELECT timesPlayed FROM User Where name =" + this.name);
|
|
|
|
String result = Game.databaseConnector.getCurrentQueryResult().getData()[0][0];
|
2022-02-20 17:44:44 +01:00
|
|
|
return Integer.parseInt(result);
|
2022-02-10 11:35:59 +01:00
|
|
|
}
|
|
|
|
|
2022-03-02 13:25:21 +01:00
|
|
|
|
2022-02-20 17:44:44 +01:00
|
|
|
public void increaseTimesPlayed()
|
2022-02-14 09:29:56 +01:00
|
|
|
{
|
2022-02-20 17:44:44 +01:00
|
|
|
int temp = getTimesPlayed();
|
|
|
|
temp++;
|
|
|
|
setTimesPlayed(temp);
|
2022-02-14 09:29:56 +01:00
|
|
|
}
|
2022-02-20 17:44:44 +01:00
|
|
|
|
2022-02-14 09:29:56 +01:00
|
|
|
|
2022-03-02 13:25:21 +01:00
|
|
|
|
2022-02-10 11:35:59 +01:00
|
|
|
public void setCurrentStreak(int currentStreak)
|
|
|
|
{
|
2022-03-07 15:38:35 +01:00
|
|
|
Game.databaseConnector.executeStatement("UPDATE User SET currentStreak = " + currentStreak + " Where name = " + this.name);
|
2022-02-10 11:35:59 +01:00
|
|
|
}
|
|
|
|
|
2022-03-02 13:25:21 +01:00
|
|
|
|
2022-02-10 11:35:59 +01:00
|
|
|
public int getCurrentStreak()
|
|
|
|
{
|
2022-03-07 15:38:35 +01:00
|
|
|
Game.databaseConnector.executeStatement("SELECT currentStreak FROM User Where name =" + this.name);
|
|
|
|
String result = Game.databaseConnector.getCurrentQueryResult().getData()[0][0];
|
2022-02-20 17:44:44 +01:00
|
|
|
return Integer.parseInt(result);
|
2022-02-10 11:35:59 +01:00
|
|
|
}
|
|
|
|
|
2022-03-02 13:25:21 +01:00
|
|
|
|
2022-02-14 09:29:56 +01:00
|
|
|
public void increaseCurrentStreak()
|
|
|
|
{
|
2022-02-20 17:44:44 +01:00
|
|
|
int temp = getCurrentStreak();
|
|
|
|
temp++;
|
|
|
|
setCurrentStreak(temp);
|
2022-02-14 09:29:56 +01:00
|
|
|
}
|
|
|
|
|
2022-02-20 17:44:44 +01:00
|
|
|
|
2022-03-02 13:25:21 +01:00
|
|
|
|
2022-02-10 11:35:59 +01:00
|
|
|
public void setMaxStreak(int maxStreak)
|
|
|
|
{
|
2022-03-07 15:38:35 +01:00
|
|
|
Game.databaseConnector.executeStatement("UPDATE User SET maxStreak = " + maxStreak + " Where name = " + this.name);
|
2022-02-10 11:35:59 +01:00
|
|
|
}
|
|
|
|
|
2022-03-02 13:25:21 +01:00
|
|
|
|
2022-02-10 11:35:59 +01:00
|
|
|
public int getMaxStreak()
|
|
|
|
{
|
2022-03-07 15:38:35 +01:00
|
|
|
Game.databaseConnector.executeStatement("SELECT maxStreak FROM User Where name =" + this.name);
|
|
|
|
String result = Game.databaseConnector.getCurrentQueryResult().getData()[0][0];
|
2022-02-20 17:44:44 +01:00
|
|
|
return Integer.parseInt(result);
|
2022-02-10 11:35:59 +01:00
|
|
|
}
|
|
|
|
|
2022-03-02 13:25:21 +01:00
|
|
|
|
2022-02-14 09:29:56 +01:00
|
|
|
public void increaseMaxStreak()
|
|
|
|
{
|
2022-02-20 17:44:44 +01:00
|
|
|
int temp = getMaxStreak();
|
|
|
|
temp++;
|
|
|
|
setMaxStreak(temp);
|
2022-02-14 09:29:56 +01:00
|
|
|
}
|
|
|
|
|
2022-02-20 17:44:44 +01:00
|
|
|
|
2022-03-02 13:25:21 +01:00
|
|
|
|
2022-02-20 17:44:44 +01:00
|
|
|
public void setWonInTurn(int row, int value)
|
2022-02-10 11:35:59 +01:00
|
|
|
{
|
2022-03-07 15:38:35 +01:00
|
|
|
Game.databaseConnector.executeStatement("UPDATE User SET wonInTurn" + row + " = " + value + " Where name = " + this.name);
|
2022-02-10 11:35:59 +01:00
|
|
|
}
|
|
|
|
|
2022-03-02 13:25:21 +01:00
|
|
|
|
2022-02-20 17:44:44 +01:00
|
|
|
public int getWonInTurn(int row)
|
2022-02-10 11:35:59 +01:00
|
|
|
{
|
2022-03-07 15:38:35 +01:00
|
|
|
Game.databaseConnector.executeStatement("SELECT wonInTurn" + row + " FROM User Where name =" + this.name);
|
|
|
|
String result = Game.databaseConnector.getCurrentQueryResult().getData()[0][0];
|
2022-02-20 17:44:44 +01:00
|
|
|
return Integer.parseInt(result);
|
2022-02-14 09:29:56 +01:00
|
|
|
}
|
2022-02-10 11:35:59 +01:00
|
|
|
|
2022-03-02 13:25:21 +01:00
|
|
|
public void increaseWonInTurn(int row)
|
|
|
|
{
|
|
|
|
int temp = getWonInTurn(row) + 1;
|
|
|
|
setWonInTurn(row, temp);
|
|
|
|
}
|
|
|
|
|
2022-02-20 17:44:44 +01:00
|
|
|
public int[] getWonInTurnFull()
|
2022-02-14 09:29:56 +01:00
|
|
|
{
|
2022-02-20 17:44:44 +01:00
|
|
|
int[] result = {getWonInTurn(1),getWonInTurn(2),getWonInTurn(3),getWonInTurn(4),getWonInTurn(5),getWonInTurn(6)};
|
|
|
|
return result;
|
2022-02-14 09:29:56 +01:00
|
|
|
}
|
2022-03-03 11:28:20 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
2022-02-20 17:44:44 +01:00
|
|
|
}
|