public class User {
    
    private String name = "default";

    /**
     * Konstruktor für Objekte der Klasse User
     */
    public User(String name)
    {
        setName(name);
    }

   
    
     public void setPassword(String password)
    {
       Game.databaseConnector.executeStatement("UPDATE User SET password = " + password + " Where name = " + this.name);       
    }
        
    
    public String getPassword()
    {
    	Game.databaseConnector.executeStatement("SELECT password FROM User Where name =" + this.name);
       String result = Game.databaseConnector.getCurrentQueryResult().getData()[0][0];
       return result;
    } 
     
    
    
    public void setName(String name)
    {
    	Game.databaseConnector.executeStatement("UPDATE User SET name = " + name + " Where name = " + this.name);
    }
    
    
    public String getName()
    {
       return name;
    }         
    
    
    
    public void setWinPercentage(float winPercentage)
    {
    	Game.databaseConnector.executeStatement("UPDATE User SET winPercentage = " + winPercentage + " Where name = " + this.name);
    }
    
    
    public float getWinPercentage()
    {
    	Game.databaseConnector.executeStatement("SELECT winPercentage FROM User Where name =" + this.name);
       String result = Game.databaseConnector.getCurrentQueryResult().getData()[0][0];      
       return Float.parseFloat(result);
    }
    
    
    
    public void setTimesPlayed(int timesPlayed)
    {
    	Game.databaseConnector.executeStatement("UPDATE User SET timesPlayed = " + timesPlayed + " Where name = " + this.name);
    }
    
    
    public int getTimesPlayed()
    {
    	Game.databaseConnector.executeStatement("SELECT timesPlayed FROM User Where name =" + this.name);
       String result = Game.databaseConnector.getCurrentQueryResult().getData()[0][0];
       return Integer.parseInt(result);
    } 
    
    
    public void increaseTimesPlayed()
    {
        int temp = getTimesPlayed();
        temp++;
        setTimesPlayed(temp);
    }
       
    
    
    public void setCurrentStreak(int currentStreak)
    {
    	Game.databaseConnector.executeStatement("UPDATE User SET currentStreak = " + currentStreak + " Where name = " + this.name);
    }
    
    
    public int getCurrentStreak()
    {
    	Game.databaseConnector.executeStatement("SELECT currentStreak FROM User Where name =" + this.name);
       String result = Game.databaseConnector.getCurrentQueryResult().getData()[0][0];
       return Integer.parseInt(result);
    } 
    
    
    public void increaseCurrentStreak()
    {
        int temp = getCurrentStreak();
        temp++;
        setCurrentStreak(temp);
    }
    
    
    
    public void setMaxStreak(int maxStreak)
    {
    	Game.databaseConnector.executeStatement("UPDATE User SET maxStreak = " + maxStreak + " Where name = " + this.name);
    }
    
    
    public int getMaxStreak()
    {
    	Game.databaseConnector.executeStatement("SELECT maxStreak FROM User Where name =" + this.name);
       String result = Game.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)
    {
    	Game.databaseConnector.executeStatement("UPDATE User SET wonInTurn" + row + " = " + value + " Where name = " + this.name);
    }
       
    
    public int getWonInTurn(int row)
    {
    	Game.databaseConnector.executeStatement("SELECT wonInTurn" + row + " FROM User Where name =" + this.name);
       String result = Game.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;
    }
    
    
    
}
