-
Notifications
You must be signed in to change notification settings - Fork 2
/
Utilizador.java
90 lines (72 loc) · 2.03 KB
/
Utilizador.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import java.io.Serializable;
import java.net.Socket;
import java.io.PrintWriter;
import java.io.IOException;
public abstract class Utilizador implements Serializable
{
private String username, password;
private boolean logged;
private Socket s;
private PrintWriter output;
public Utilizador(String username, String password, boolean logged){
this.username = username;
this.password = password;
this.logged = logged;
}
public Utilizador(){
this("","", false);
}
public Utilizador(Utilizador u){
this.username = u.getUsername();
this.password = u.getPassword();
this.logged = u.getLogged();
}
public void send(String msg){
output.println(msg);
}
public Socket getS(){
return s;
}
public void setS(Socket s) throws IOException{
this.s = s;
output = new PrintWriter(s.getOutputStream(), true);
}
public String getPassword(){
return password;
}
public String getUsername() {
return username;
}
public boolean getLogged() {
return logged;
}
public void setPassword(String password){
this.password = password;
}
public void setUsername(String username) {
this.username = username;
}
public void setLogged(boolean logged) {
this.logged = logged;
}
public boolean equals(Object o){
if(this == o)
return true;
if ((o==null) || (this.getClass() != o.getClass()))
return false;
Utilizador m = (Utilizador) o;
return (this.password.equals(m.getPassword()) &&
this.username.equals(m.getUsername()));
}
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("Password: ").append(password).append("\n");
sb.append("Username: ").append(password).append("\n");
return sb.toString();
}
@Override
public abstract Utilizador clone();
/*public int hashCode(){
return this.email.hashCode();
}*/
}