import java.net.*; import java.io.*; public class TripsuMang extends Thread{ //1-X 2-0 BufferedReader sisse1, sisse2; PrintWriter valja1, valja2; boolean veel=true; TripsuLaud laud1=new TripsuLaud(); public TripsuMang(Socket usc1, Socket usc2){ try{ sisse1=new BufferedReader(new InputStreamReader(usc1.getInputStream())); sisse2=new BufferedReader(new InputStreamReader(usc2.getInputStream())); valja1=new PrintWriter(usc1.getOutputStream(), true); valja2=new PrintWriter(usc2.getOutputStream(), true); start(); }catch(Exception ex){ ex.printStackTrace(); } } void teeKaik(PrintWriter valja, BufferedReader sisse, char symbol) { boolean uuesti=true; do{ try{ valja.println("Sinu kord: (rida veerg 0..2)"); String rida=sisse.readLine(); String[] kaik=rida.split(" "); laud1.paiguta(Integer.parseInt(kaik[0]), Integer.parseInt(kaik[1]), symbol); uuesti=false; valja1.println(laud1.toString()); valja2.println(laud1.toString()); }catch(IOException ioe){ uuesti=false; }catch(Exception ex){ ex.printStackTrace(valja); System.out.println(ex); ex.printStackTrace(); } } while (uuesti); } public void run(){ try{ while(veel){ teeKaik(valja1, sisse1, 'X'); teeKaik(valja2, sisse2, 'O'); } } catch(Exception ex){ex.printStackTrace();} } }