Skip to content

Instantly share code, notes, and snippets.

@MojamojaK
Created April 16, 2018 08:03
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/cb85f00e3bd46a1d70c0ce07a9d29a91 to your computer and use it in GitHub Desktop.
Save MojamojaK/cb85f00e3bd46a1d70c0ce07a9d29a91 to your computer and use it in GitHub Desktop.
// Client using threaded 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) {
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