当前位置: 技术问答>java相关
救命,明天就验收程序了,可是还……,500分!我分几次给!
来源: 互联网 发布时间:2015-07-12
本文导语: 所有的工作都做好了,可是server和socket就是连不起来,数据也传不过去,恶心! 请各位高手帮忙看看,我所有的分全给你们! 程序如下:(五子棋) //server: import java.awt.*; import java.awt.event.*; import java.net.*; import ...
所有的工作都做好了,可是server和socket就是连不起来,数据也传不过去,恶心!
请各位高手帮忙看看,我所有的分全给你们!
程序如下:(五子棋)
//server:
import java.awt.*;
import java.awt.event.*;
import java.net.*;
import java.io.*;
public class ServerWindow extends Frame{
DrawWindow d=new DrawWindow();
TextField c=new TextField("fuwuqi");
ServerWindow(){
super("服务器");
setLayout(new FlowLayout());
add(d);
add(c);
d.requestFocus();
setSize(600,500);
setVisible(true);
addWindowListener(new closeWin());
try{
d.connect();
}catch (Exception e){}
}
public static void main(String[] args){
new ServerWindow();
}
}
//************************************************
class DrawWindow extends Canvas{
int postion[][]=new int[20][20];
public int yx=10,yy=10;
DataInputStream dis;
DataOutputStream dos;
ServerSocket s;
Socket ss;
//构造函数
DrawWindow(){
addMouseListener(new MouseAdpt(this));
setSize(440,440);
setBackground(Color.orange);
setVisible(true);
}
//我觉得就是这段程序不对,可是不知哪不对?
//?????????????????????????
public void connect()throws Exception{
s=new ServerSocket(8888);
ss=s.accept();
try{
while (true){
dis=new DataInputStream(ss.getInputStream());
dos=new DataOutputStream(ss.getOutputStream());
myThread mt=new myThread(this);
mt.start();
}
}catch(Exception e){}
}
//?????????????????????????????????????
public void senddata(int x){
try{
dos.writeInt(x);
dos.flush();
}catch (Exception e){}
}
public int getdata(){
int t=0;
try
{t=dis.readInt();
}catch (Exception e){}
return t;
}
//画棋盘和棋子
public void paint(Graphics g){
int i,j,x,y;
//画棋盘格
for (i=1;i
请各位高手帮忙看看,我所有的分全给你们!
程序如下:(五子棋)
//server:
import java.awt.*;
import java.awt.event.*;
import java.net.*;
import java.io.*;
public class ServerWindow extends Frame{
DrawWindow d=new DrawWindow();
TextField c=new TextField("fuwuqi");
ServerWindow(){
super("服务器");
setLayout(new FlowLayout());
add(d);
add(c);
d.requestFocus();
setSize(600,500);
setVisible(true);
addWindowListener(new closeWin());
try{
d.connect();
}catch (Exception e){}
}
public static void main(String[] args){
new ServerWindow();
}
}
//************************************************
class DrawWindow extends Canvas{
int postion[][]=new int[20][20];
public int yx=10,yy=10;
DataInputStream dis;
DataOutputStream dos;
ServerSocket s;
Socket ss;
//构造函数
DrawWindow(){
addMouseListener(new MouseAdpt(this));
setSize(440,440);
setBackground(Color.orange);
setVisible(true);
}
//我觉得就是这段程序不对,可是不知哪不对?
//?????????????????????????
public void connect()throws Exception{
s=new ServerSocket(8888);
ss=s.accept();
try{
while (true){
dis=new DataInputStream(ss.getInputStream());
dos=new DataOutputStream(ss.getOutputStream());
myThread mt=new myThread(this);
mt.start();
}
}catch(Exception e){}
}
//?????????????????????????????????????
public void senddata(int x){
try{
dos.writeInt(x);
dos.flush();
}catch (Exception e){}
}
public int getdata(){
int t=0;
try
{t=dis.readInt();
}catch (Exception e){}
return t;
}
//画棋盘和棋子
public void paint(Graphics g){
int i,j,x,y;
//画棋盘格
for (i=1;i