-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClient.java
More file actions
70 lines (51 loc) · 1.73 KB
/
Copy pathClient.java
File metadata and controls
70 lines (51 loc) · 1.73 KB
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
import java.io.*;
import java.net.*;
public class Client
{
private final String nomEquipe = "C++ ce que c'était\n";
private DataInputStream inputSocket;
private DataOutputStream outputSocket;
private BufferedReader readerIn;
private String serverAddr;
private int portServ;
private String numeroEquipe;
public Client(String serverAddr,int portServ)
{
this.serverAddr = serverAddr;
this.portServ = portServ;
}
public void connectToServer() throws IOException {
Socket socket = new Socket(this.serverAddr, this.portServ);
this.inputSocket = new DataInputStream(socket.getInputStream());
this.outputSocket = new DataOutputStream(socket.getOutputStream());
this.readerIn = new BufferedReader(new InputStreamReader(socket.getInputStream()));
//ENVOI NOM EQUIPE
this.outputSocket.writeBytes(this.nomEquipe);
this.numeroEquipe = this.readerIn.readLine();
System.out.println(this.numeroEquipe);
// System.out.println(Integer.parseInt(this.numeroEquipe(
}
public void play()
{
try{
String stringPlateau = this.readerIn.readLine();
//System.out.println("StringPlateau : "+stringPlateau);
Algo algorithme = new Algo();
Plateau p;
String instruction;
p = new Plateau(stringPlateau, new Integer(this.numeroEquipe).intValue());
do
{
p.majTab(stringPlateau);
//System.out.println(p.toString());
instruction = algorithme.deplacerJoueur(p)+"\n";
//System.out.println(instruction);
this.outputSocket.writeBytes(instruction);
stringPlateau = this.readerIn.readLine();
}while(!stringPlateau.equals("FIN"));
}catch(IOException e)
{
System.out.println("play error");
}
}
}