ajout d'un id a chaque utilisateur
This commit is contained in:
parent
824c1522d6
commit
a025a305fd
2 changed files with 9 additions and 0 deletions
Binary file not shown.
|
@ -6,10 +6,13 @@ public class Utilisateur extends Object {
|
|||
private String pseudo ;
|
||||
private Integer port;
|
||||
private InetAddress ip ;
|
||||
private String id ;
|
||||
|
||||
public Utilisateur(String pseudo,Integer port, InetAddress ip ){
|
||||
this.setPseudo(pseudo) ;
|
||||
this.setPort(port);
|
||||
this.ip = ip ;
|
||||
this.id = ip.getHostName() ;
|
||||
}
|
||||
|
||||
public String getPseudo() {
|
||||
|
@ -31,6 +34,9 @@ public class Utilisateur extends Object {
|
|||
public InetAddress getIp() {
|
||||
return ip;
|
||||
}
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
|
@ -38,6 +44,7 @@ public class Utilisateur extends Object {
|
|||
s+="pseudo " + this.pseudo + " | ";
|
||||
s+="port " + (this.port).toString() + " | ";
|
||||
s+="ip " + (this.ip).toString() + " | ";
|
||||
s+="id " + (this.id).toString() + " | ";
|
||||
return s;
|
||||
}
|
||||
|
||||
|
@ -45,10 +52,12 @@ public class Utilisateur extends Object {
|
|||
String name = "";
|
||||
Integer port = 0;
|
||||
String ip = "" ;
|
||||
String id = "";
|
||||
String mots[] = s.split(" ");
|
||||
name=mots[1];
|
||||
port=Integer.parseInt(mots[4]);
|
||||
ip=mots[7];
|
||||
id=mots[10];
|
||||
Utilisateur user = null;
|
||||
try {
|
||||
user = new Utilisateur(name,port,InetAddress.getByName(ip.split("/")[0]));
|
||||
|
|
Loading…
Reference in a new issue