java tcp/ip一个小问题

fchong 2003-09-03 10:52:33
以下是一个协议列表,我编译时,出现了如下错误:

EmployProtocol.java:100: '}' expected
}
^
EmployProtocol.java:13: cannot resolve symbol
symbol : class vector
location: class EmployProtocol
private vector candidate = new Vector();
^
EmployProtocol.java:26: cannot resolve symbol
symbol : class Vector
location: class EmployProtocol
private Vector candidate = new Vector();
^
EmployProtocol.java:13: cannot resolve symbol
symbol : class Vector
location: class EmployProtocol
private vector candidate = new Vector();
^
EmployProtocol.java:26: cannot resolve symbol
symbol : class Vector
location: class EmployProtocol
private Vector candidate = new Vector();

------------------------
以下为程序代码

import java.net.*;
import java.io.*;
public class EmployProtocol {
private static final int WAIT = 0;
private static final int REGISTER = 1;
private static final int READY = 2;
private static final int ANSWER = 3;
private static final int OUT = 4;
private static final int END = 5;
private int state = WAIT;
private int currentQuestion = 0;
private int score = 0;
private vector candidate = new Vector();
private String[] question = {
"master Java ? ",
"one year + experience ? ",
"master TCP/IP ? ",
"master jsp ? ",
"master servlet ? ",
"master ejb ? ",
"master IDE tools like visual caff... ?",
"master oracle database ?",
"master middleware like weblogic… ?" };
private int[] right = {5,5,5,1,1,1,2,2,2};
private boolean[] must = {true,true,true,false,false,false,false,false,false};
private Vector candidate = new Vector();
//该方法实现对用户输入的判断,同时实现了协议的逻辑
public String judge(String theInput)
{
String theOutput = null;
//用户为等待状态,提示用户输入用户名,并将状态转为注册态
if (state == WAIT)
{
theOutput = "Register: please input your name. confirm it and Press enter key;";
state = REGISTER;
}
//当用户为注册状态,提示用户使用方法,并将状态转为准备态
else if (state == REGISTER)
{
candidate.add(theInput);
theOutput = "hint: you can only press Y or N after you read the question. ";
state = READY;
}
//当用户为准备状态,显示第一个问题,并将状态转为填表态
else if(state == READY)
{
state = ANSWER;
theOutput = question[currentQuestion] + " [Y/N]";
}
//当用户为填表状态,显示问题
else if(state == ANSWER)
{
//准备下一个问题
if(currentQuestion<question.length-1)
theOutput = question[currentQuestion+1] + " [Y/N]";
//如果用户的回答为Y
if(theInput.equalsIgnoreCase("Y"))
{
//增加用户得分
score = score + right[currentQuestion];
//如果用户已经回答了最后一个问题,转换状态为end
if(currentQuestion==question.length-1) state = END;
else currentQuestion=currentQuestion + 1;
}
//如果用户的回答为N
else if(theInput.equalsIgnoreCase("N"))
{
//明显不合条件的将被中断
if(must[currentQuestion]) state = OUT;
if(currentQuestion==question.length-1) state = END;
else currentQuestion=currentQuestion + 1;
}
else if(theInput.equalsIgnoreCase("bye"))
{
}
else
{
//如果用户回答不合要求,给出提示,要求重新回答
theOutput = "you only need to anwer y or n";
state = READY;
}
//如果用户状态为OUT,给出提示信息,重置变量
if (state == OUT)
{
theOutput = "sorry you are not suit our require!!!";
state = WAIT;
score = 0;
currentQuestion = 0;
}
//如果用户状态为END,给出提示信息,重置变量
else if (state == END)
{
theOutput = "Congratulation !! you are indeed we want,your evaluation value is " + score;
state = WAIT;
score = 0;
currentQuestion = 0;
}
return theOutput;
}
}
...全文
28 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
fchong 2003-09-03
  • 打赏
  • 举报
回复
对了,忘了写了,刚开始我就是大写的 Vector

也提示同样的问题!
taolei 2003-09-03
  • 打赏
  • 举报
回复
import java.util.*;

vector改成Vector
storm999 2003-09-03
  • 打赏
  • 举报
回复
隨便找了几個問題﹐你先改了吧﹗
1.最后少了一個'}';
2.引入包java.until.Vector;
3.public String judge(String theInput) 這個方法沒有返回類型
4.candidate聲明了兩次

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧