📄 employprotocol.java
字号:
import java.net.*;
import java.io.*;
import java.util.*;
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 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]";
if(theInput.equalsIgnoreCase("Y"))
{
score = score + right[currentQuestion];
if(currentQuestion==question.length-1) state = END;
else currentQuestion=currentQuestion + 1;
}
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;
}
if (state == OUT)
{
theOutput = "sorry you are not suit our require!!!";
state = WAIT;
score = 0;
currentQuestion = 0;
}
else if (state == END)
{
theOutput = "Congratulation !! you are indeed we want,your evaluation value is " + score;
state = WAIT;
score = 0;
currentQuestion = 0;
}
}
return theOutput;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -