package model;

import java.net.*;

public abstract class User {
	
	
	/*** ATTRIBUTS ***/
	protected String pseudo;
	protected InetAddress addIP;
	protected int portTCP;
	protected int IPcode;
	
	/**
	 *  Constructor of User (local)
	 * @parametres
	 * 		@param pseudo : String
	 * 		@param addIP : InetAddress
	 * 		@param portTCP : int => le numéro de port pour commencer une nouvelle conversation
	 * @description
	 * <p>
	 * 		
	 * </p>
	 */
	public User(String pseudo,InetAddress addIP,int portTCP){
		this.pseudo = pseudo;
		this.addIP=addIP;
		this.portTCP=portTCP;
		this.IPcode=addIP.hashCode();
	}

	
	/*** GETTERS ***/
	public int getIPcode() {
		return IPcode;
	}
	public String getPseudo() {
		return pseudo;
	}
	public InetAddress getAddIP() {
		return addIP;
	}
	public int getPortTCP() {
		return portTCP;
	}

	
	/*** SETTERS ***/
	public void setPseudo(String pseudo) {
		this.pseudo = pseudo;
	}
	public void setAddIP(InetAddress addIP) {
		this.addIP = addIP;
	}
	public void setPortTCP(int portTCP) {
		this.portTCP = portTCP;
	}

	
	
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		User other = (User) obj;
		if (addIP == null) {
			if (other.addIP != null)
				return false;
		} else if (!addIP.equals(other.addIP))
			return false;
		if (portTCP != other.portTCP)
			return false;
		return true;
	}
}
