public class User
{
    
    static DatabaseConnector databaseConnector;// Datenbankverbindung aufstellen
    private String name = "default";

    /**
     * Konstruktor für Objekte der Klasse User
     */
    public User(String name)
    {
        databaseConnector = new DatabaseConnector("", 0, "wordle.db", "", "");
        setName(name);
    }

   
    
     public void setPassword(String password)
    {
       databaseConnector.executeStatement("UPDATE User SET password = " + password + " Where name = " + this.name);       
    }
        
    
    public String getPassword()
    {
       databaseConnector.executeStatement("SELECT password FROM User Where name =" + this.name);
       String result = databaseConnector.getCurrentQueryResult().getData()[0][0];
       return result;
    } 
     
    
    
    public void setName(String name)
    {
        databaseConnector.executeStatement("UPDATE User SET name = " + name + " Where name = " + this.name);
    }
    
    
    public String getName()
    {
       return name;
    }         
    
    
    
    public void setWinPercentage(float winPercentage)
    {
        databaseConnector.executeStatement("UPDATE User SET winPercentage = " + winPercentage + " Where name = " + this.name);
    }
    
    
    public float getWinPercentage()
    {
       databaseConnector.executeStatement("SELECT winPercentage FROM User Where name =" + this.name);
       String result = databaseConnector.getCurrentQueryResult().getData()[0][0];      
       return Float.parseFloat(result);
    }
    
    
    
    public void setTimesPlayed(int timesPlayed)
    {
        databaseConnector.executeStatement("UPDATE User SET timesPlayed = " + timesPlayed + " Where name = " + this.name);
    }
    
    
    public int getTimesPlayed()
    {
       databaseConnector.executeStatement("SELECT timesPlayed FROM User Where name =" + this.name);
       String result = databaseConnector.getCurrentQueryResult().getData()[0][0];
       return Integer.parseInt(result);
    } 
    
    
    public void increaseTimesPlayed()
    {
        int temp = getTimesPlayed();
        temp++;
        setTimesPlayed(temp);
    }
       
    
    
    public void setCurrentStreak(int currentStreak)
    {
        databaseConnector.executeStatement("UPDATE User SET currentStreak = " + currentStreak + " Where name = " + this.name);
    }
    
    
    public int getCurrentStreak()
    {
       databaseConnector.executeStatement("SELECT currentStreak FROM User Where name =" + this.name);
       String result = databaseConnector.getCurrentQueryResult().getData()[0][0];
       return Integer.parseInt(result);
    } 
    
    
    public void increaseCurrentStreak()
    {
        int temp = getCurrentStreak();
        temp++;
        setCurrentStreak(temp);
    }
    
    
    
    public void setMaxStreak(int maxStreak)
    {
        databaseConnector.executeStatement("UPDATE User SET maxStreak = " + maxStreak + " Where name = " + this.name);
    }
    
    
    public int getMaxStreak()
    {
       databaseConnector.executeStatement("SELECT maxStreak FROM User Where name =" + this.name);
       String result = databaseConnector.getCurrentQueryResult().getData()[0][0];
       return Integer.parseInt(result);       
    } 
    
    
    public void increaseMaxStreak()
    {
        int temp = getMaxStreak();
        temp++;
        setMaxStreak(temp);
    }
    
    
    
    public void setWonInTurn(int row, int value)
    {
        databaseConnector.executeStatement("UPDATE User SET wonInTurn" + row + " = " + value + " Where name = " + this.name);
    }
       
    
    public int getWonInTurn(int row)
    {
       databaseConnector.executeStatement("SELECT wonInTurn" + row + " FROM User Where name =" + this.name);
       String result = databaseConnector.getCurrentQueryResult().getData()[0][0];
       return Integer.parseInt(result);  
    }   
    
    public void increaseWonInTurn(int row)
    {
        int temp = getWonInTurn(row) + 1;
        setWonInTurn(row, temp);
    }
    
    public int[] getWonInTurnFull()
    {
       int[] result = {getWonInTurn(1),getWonInTurn(2),getWonInTurn(3),getWonInTurn(4),getWonInTurn(5),getWonInTurn(6)};
       return result;
    }
    
    
    
}
