-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathData.java
executable file
·108 lines (92 loc) · 2.48 KB
/
Data.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import java.util.Vector;
public class Data {
public static Vector<ProprieteClient> clientConnected;
public static Vector<ProprieteGroup> groupConnected;
public Data(){
clientConnected = new Vector<ProprieteClient>();
groupConnected = new Vector<ProprieteGroup>();
}
public void recordClient(ProprieteClient client){
clientConnected.add(client);
}
public void recordGroup(ProprieteGroup g){
groupConnected.add(g);
}
public int tailleClient(){
return clientConnected.size();
}
public int tailleGroup(){
return groupConnected.size();
}
public void removeClient(ProprieteClient client){
clientConnected.remove(client);
}
public void removeGroup(ProprieteGroup g){
groupConnected.remove(g);
}
public void Toutsuprimer(){
clientConnected.removeAllElements();
}
public void ToutsuprimerGroup(){
groupConnected.removeAllElements();
}
public boolean Trouver(ProprieteClient client){
return clientConnected.contains(client);
}
public boolean TrouverGroup(ProprieteGroup g){
return groupConnected.contains(g);
}
public ProprieteClient Trouver2(String pseudo){
for(int i=0;i<clientConnected.size();i++){
ProprieteClient data = clientConnected.get(i);
if(data.getPseudo().equals(pseudo) ){
return data;
}
}
return null;
}
public ProprieteGroup TrouverGroup2(String nom){
for(int i=0;i<groupConnected.size();i++){
ProprieteGroup data = groupConnected.get(i);
if(data.getNom().equals(nom) ){
return data;
}
}
return null;
}
public void ClientConnected (int LocalPort){
if(clientConnected.size()==0){
System.out.print("0 clients connectes");
return;
}
System.out.println("Liste Client ConnectŽs :");
for(int i=0;i<clientConnected.size();i++){
ProprieteClient c = clientConnected.get(i);
String pseudo = c.getPseudo();
String adr = c.getAddr();
int p = c.getPort();
if(LocalPort != p ){
// && !this.getAddr().equals(addr)
System.out.println("n¡" + i +" : "+ pseudo +
" | Adresse : " + adr +
" | Port : " + p);
}
}
}
public void GroupConnected (){
if(groupConnected.size()==0){
System.out.print("0 Groupes prŽsents");
return;
}
System.out.println("Liste Groupes PrŽsents :");
for(int i=0;i<groupConnected.size();i++){
ProprieteGroup c = groupConnected.get(i);
String nom = c.getNom();
String adr = c.getAddressMulticast();
int p = c.getPortMulticast();
System.out.println("n¡" + i +" : "+ nom +
" | Adresse : " + adr +
" | Port : " + p);
}
}
}