Hangman+Judge

Source Code code format="java5"

import java.util.LinkedHashSet; import java.util.Scanner; import java.util.Set;

public class HangmanJudge { private static int LIFE = 7;// ���� ���� private enum Result {WIN, LOSE, CHICKENED_OUT}// ���� �� �ִ� ��� public static void main(String[] args) { Scanner scan = new Scanner(System.in); while(scan.hasNextInt) { int r = scan.nextInt;// ���� �� if(r == -1) { System.exit(0); }   System.out.println("Round " + r); String sol = scan.next;// ���� �ܾ� String ges = scan.next;// ������ �ܾ� switch(judge(sol, ges)) { case WIN: System.out.println("You win."); break; case LOSE: System.out.println("You lose."); break; case CHICKENED_OUT: System.out.println("You chickened out."); break; }   }    }    private static Result judge(String sol, String ges) { // �ߺ��� ���ĺ��� �����Ѵ�. Set solSet = new LinkedHashSet; for(char ch : sol.toCharArray) { solSet.add(ch); }   // �ߺ��� ���ĺ��� �����Ѵ�. Set gesSet = new LinkedHashSet; for(char ch : ges.toCharArray) { gesSet.add(ch); }   int c = 0; for(char ch : gesSet) { // ���ڰ� ��ġ�ϸ� �����, ��ġ���� ������ ���� ó���Ѵ�. if(!solSet.remove(ch)) { c++; }   // ��� ���߸� �̱��.    if(solSet.size == 0) { return Result.WIN; }   // ���� ���� �̻� Ʋ���� ���. if(c >= LIFE) { return Result.LOSE; }   }    // ���ڸ� �ٽ�µ� ��� �ȳ��� ������ ������ �����Ѵ�. return Result.CHICKENED_OUT; }   }

code