package com.gruppe27.fellesprosjekt.common;


import java.util.HashSet;
import java.util.Set;


public class User {

    private String username;

    private String name;

    private int teamNo;

    private HashSet<Event> events;
    private Set<Group> groups;

    public User() {}

    public User(String username, String name) {
        this.setName(name);
        this.setUsername(username);
        groups = new HashSet<>();
    }

    @Override
    public String toString() {

        return "User{" +
                "groups=" + groups +
                ", username='" + username + '\'' +
                ", name='" + name + '\'' +
                ", teamNo=" + teamNo +
                '}';

    }


    /**
     * Takes in a group and adds it to the user's other groups
     * @param group
     */
    public void addUserToGroup(Group group) {
        if (!groups.contains(group)) {
            groups.add(group);
            group.addUser(this);
        }
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public int getTeamNo() {
        return teamNo;
    }

    public void setTeamNo(int teamNo) {
        this.teamNo = teamNo;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void removeUserFromGroup(Group group) {
        if (groups.contains(group)) {
            groups.remove(group);
            group.removeUser(this);
        }
    }

    public void addEvent(Event event) {
        if(!events.contains(event)) {
            events.add(event);
            event.addParticipant(this);
        }
    }
}

@@ -170,32 +170,9 @@
 e;%0A%0A
-    private int teamNo;
 %0A
+
 %0A   
@@ -616,47 +616,8 @@
 ' +%0A
-                %22, teamNo=%22 + teamNo +%0A
     
@@ -1065,142 +1065,8 @@
  %7D%0A%0A
-    public int getTeamNo() %7B%0A        return teamNo;%0A    %7D%0A%0A    public void setTeamNo(int teamNo) %7B%0A        this.teamNo = teamNo;%0A    %7D
 %0A%0A  

remove teamno from user