Changed ints to strings on difficulty setting.
This commit is contained in:
parent
55df700301
commit
e6edce2103
2 changed files with 8 additions and 9 deletions
11
Client.java
11
Client.java
|
@ -272,15 +272,14 @@ public class Client {
|
|||
userInput = stdIn.readLine();
|
||||
output.println(userInput);
|
||||
|
||||
int diff = 0;
|
||||
String diff = "?";
|
||||
in.read(b, 0, 256);
|
||||
temp = String.valueOf(b).trim();
|
||||
System.out.print(temp);
|
||||
while(diff < 1 || diff > 3) {
|
||||
userInput = stdIn.readLine();
|
||||
diff = Integer.parseInt(userInput);
|
||||
if(diff < 1 || diff > 3) {
|
||||
System.out.print("Invalid difficulty.\n" + temp);
|
||||
while(!diff.equals("EASY") && !diff.equals("MEDIUM") && !diff.equals("HARD")) {
|
||||
diff = stdIn.readLine();
|
||||
if(!diff.equals("EASY") && !diff.equals("MEDIUM") && !diff.equals("HARD")) {
|
||||
System.out.print(diff + "\nInvalid difficulty.\n" + temp);
|
||||
}
|
||||
}
|
||||
output.println(userInput);
|
||||
|
|
|
@ -122,7 +122,7 @@ int main(int argc, char *argv[])
|
|||
write(newsockfd, difficulty_select.c_str(), difficulty_select.length());
|
||||
n = read(newsockfd,info,255);
|
||||
istringstream con(info);
|
||||
int choice_difficulty = 1;
|
||||
string choice_difficulty = "EASY";
|
||||
con >> choice_difficulty;
|
||||
cout << "OK" << endl;
|
||||
bzero(info,256);
|
||||
|
@ -159,9 +159,9 @@ int main(int argc, char *argv[])
|
|||
|
||||
while(e.getBoard()->getTurn() == 'X' )
|
||||
{
|
||||
if(choice_difficulty == 1)
|
||||
if(choice_difficulty == "EASY")
|
||||
e.AI(3);
|
||||
else if(choice_difficulty == 2)
|
||||
else if(choice_difficulty == "MEDIUM")
|
||||
e.AI(5);
|
||||
else
|
||||
e.AI(7);
|
||||
|
|
Reference in a new issue