/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Gomoku;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Administrator
 */
public class ChessController {

    BufferedReader input;
    PrintWriter output;
    String ip;
    String port;
    MyPanel mp;

    public ChessController(MyPanel mp) {
        this.mp = mp;
    }

    public String arrToString(int[][] arr) {
        String temp = "";

        return temp;
    }
    public int[][] StringToArr(String s) {
        int[][] arr = new int[15][15];
        
        return arr;
    }

    public void run() throws InterruptedException, IOException {
        while (true) {
            output.println(arrToString(mp.getArr()));
            output.flush();
            mp.setOpponentArr(StringToArr(input.readLine()));
            mp.repaint();
            Thread.sleep(1000);
        }
    }

    public void client() {
        try {
            Socket socket = new Socket(ip, Integer.parseInt(port));
            input = new BufferedReader(new InputStreamReader(socket.getInputStream()));
            output = new PrintWriter(new OutputStreamWriter(socket.getOutputStream()));
        } catch (UnknownHostException ex) {
            Logger.getLogger(ChessController.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(ChessController.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public void server() {
        try {
            ServerSocket ss = new ServerSocket(50000);
            Socket socket = ss.accept();
            input = new BufferedReader(new InputStreamReader(socket.getInputStream()));
            output = new PrintWriter(new OutputStreamWriter(socket.getOutputStream()));
        } catch (IOException ex) {
            Logger.getLogger(ChessController.class.getName()).log(Level.SEVERE, null, ex);
        }

    }
}

@@ -618,16 +618,58 @@
 anel mp;
+%0A    int%5B%5D%5B%5D arr;%0A    int%5B%5D%5B%5D opponentArr;
 %0A%0A    pu
@@ -800,15 +800,167 @@
 temp
- = 
+=
 %22%22;%0A
+        int x=arr.length;%0A        for(int i=0;i%3Carr.length;i++)%0A            for(int j=0;j%3Carr.length;j++)%0A                temp+=String.valueOf(arr%5Bi%5D%5Bj%5D);
 %0A   
@@ -979,24 +979,25 @@
 temp;%0A    %7D%0A
+%0A
     public i
@@ -1042,63 +1042,293 @@
  int
-%5B%5D%5B%5D arr = new int%5B15%5D%5B15%5D;%0A        %0A        return arr
+ num=(int)Math.sqrt(s.length());%0A        int%5B%5D%5B%5D temp=new int%5Bnum%5D%5Bnum%5D;%0A        for(int i=0;i%3Carr.length;i++)%0A            for(int j=0;j%3Carr.length;j++)%0A            %7B%0A              temp%5Bi%5D%5Bj%5D=Integer.parseInt(s.substring(i*num+j, i*num+j+1));%0A            %7D%0A        %0A        return temp
 ;%0A  
@@ -2647,21 +2647,444 @@
 ;%0A        %7D%0A
+    %7D%0A%0A    /**%0A     * @return the ip%0A     */%0A    public String getIp() %7B%0A        return ip;%0A    %7D%0A%0A    /**%0A     * @param ip the ip to set%0A     */%0A    public void setIp(String ip) %7B%0A        this.ip = ip;%0A    %7D%0A%0A    /**%0A     * @return the port%0A     */%0A    public String getPort() %7B%0A        return port;%0A    %7D%0A%0A    /**%0A     * @param port the port to set%0A     */%0A    public void setPort(String port) %7B%0A        this.port = port;
 %0A    %7D%0A%7D%0A

add two function