Skip to content

Instantly share code, notes, and snippets.

@MojamojaK
Created April 16, 2018 08:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MojamojaK/92d8d7150f0af286a98ff5021d7e7784 to your computer and use it in GitHub Desktop.
Save MojamojaK/92d8d7150f0af286a98ff5021d7e7784 to your computer and use it in GitHub Desktop.
// Client with unthreaded ClientCommunication
import java.io.*;
import java.net.*;
import java.util.Scanner;
public class Client{
public static void main(String[] args) throws IOException{
ClientCommunication comm = new ClientCommunication(args);
while (true) {
comm.update();
Scanner sc=new Scanner(System.in);
char hand = (char)sc.nextByte(); //何を出すかを入力
comm.sendMessage(hand);
if (comm.inboxSize() > 0) {
char message = comm.getMessage();
System.out.println(message); //勝敗を出力
if(message == 'l' || message == 'c') { //loseが送られてきたら終わり
break;
}
}
}
comm.sendMessage('e');
comm.close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment