Скачиваний:
66
Добавлен:
09.05.2014
Размер:
1.25 Кб
Скачать
package mainframe;

import java.net.*;
import java.io.*;

class PointHandler implements Runnable {

private Thread t;
private Socket socket;
private DataInputStream dis;
private DataOutputStream dos;
private double x;
private double y;
private double R;
private boolean answer;

PointHandler(Socket s) {
t = new Thread(this);
socket = s;
t.start();
}

public void run() {
try {
dis = new DataInputStream(socket.getInputStream());
dos = new DataOutputStream(socket.getOutputStream());

x = dis.readDouble();
y = dis.readDouble();
R = dis.readDouble();

if ((x>=0 && y>=0 && x<=R && y<=R/2) ||
(x<=0 && y>=0 && ((x*x + y*y) <= R*R/4)) ||
(x<=0 && y<=0 && y>=(-x-R))) {
answer = true;
} else {
answer = false;
}

dos.writeBoolean(answer);

dis.close();
dos.close();
socket.close();
} catch (IOException e) {
System.out.println("Unable to read/write data!");
return;
}
}
}
Соседние файлы в папке mainframe