import java.util.Random;
import java.util.Scanner;
import java.util.InputMismatchException;

/**
 *
 * @author umyu
 */
public class Main {

    public static void main(String[] args) {
        GamePlay game = new GamePlay();
        Actor player = new Player();
        Actor computer = new Computer();
        while (!game.isGameOver()) {
            try {
                System.out.println("ジャンケンゲームです！あなたの手を入力してください グー：0 チョキ：1 パー：2");
                System.out.println("コンピュータに" + GamePlay.MAX_LOSE_COUNT + "回負けたら終了です。");
                game.determineWinner(player.choice(), computer.choice());
            } catch (InputMismatchException ex) {
                System.out.println("0.1.2.以外は入力しないでください");
            }
        }
        System.out.println(GamePlay.MAX_LOSE_COUNT + "回負けたので終了です");
    }
}

enum Judge {
    Win,
    Lose,
    Draw,
}

enum Hand {
    グー,
    チョキ,
    パー;

    static Hand valueOf(int i) {
        return Hand.values()[i];
    }

    static Judge judge(Hand handA, Hand handB) {
        if (handA.equals(handB)) {
            // Draw
            return Judge.Draw;
        }
        switch (handA) {
            case グー:
                if (handB == Hand.チョキ) {
                    return Judge.Win;
                }
                break;
            case チョキ:
                if (handB == Hand.パー) {
                    return Judge.Win;
                }
                break;
            case パー:
                if (handB == Hand.グー) {
                    return Judge.Win;
                }
                break;
        }
        return Judge.Lose;
    }
}

interface Actor {

    Hand choice();
}

class Player implements Actor {

    private final Scanner scanner = new Scanner(System.in);

    @Override
    public Hand choice() {
        int hand = scanner.nextInt(3);
        scanner.reset();
        return Hand.valueOf(hand);
    }
}

class Computer implements Actor {

    private final Random random = new Random();

    @Override
    public Hand choice() {
        int hand = random.nextInt(3);
        return Hand.valueOf(hand);
    }
}

class GamePlay {

    public static final int MAX_LOSE_COUNT = 3;
    private int winCount = 0;
    private int loseCount = 0;
    private int drawCount = 0;

    void determineWinner(Hand playerhand, Hand computerhand) {
        System.out.println("あなたの手は" + playerhand);
        System.out.println("コンピュータは" + computerhand);
        switch (Hand.judge(playerhand, computerhand)) {
            case Win:
                System.out.println("勝ち");
                winCount++;
                break;
            case Lose:
                System.out.println("負け");
                loseCount++;
                break;
            case Draw:
                System.out.println("引き分け");
                drawCount++;
                break;
        }
        System.out.println("勝った回数:" + winCount + "/負けた回数:" + loseCount + "/引きわけの回数:" + drawCount + "");
    }

    boolean isGameOver() {
        return loseCount >= MAX_LOSE_COUNT;
    }
}

@@ -1,24 +1,25 @@
+%0A
 import java.util.Random;
@@ -1050,28 +1050,8 @@
 ) %7B%0A
-            // Draw%0A
     
@@ -1154,28 +1154,32 @@
    if (handB
- == 
+.equals(
 Hand.%E3%83%81%E3%83%A7%E3%82%AD) %7B%0A
@@ -1175,16 +1175,17 @@
 and.%E3%83%81%E3%83%A7%E3%82%AD)
+)
  %7B%0A     
@@ -1309,20 +1309,24 @@
 andB
- == 
+.equals(
 Hand.%E3%83%91%E3%83%BC)
  %7B%0A 
@@ -1321,16 +1321,17 @@
 Hand.%E3%83%91%E3%83%BC)
+)
  %7B%0A     
@@ -1454,20 +1454,24 @@
 andB
- == 
+.equals(
 Hand.%E3%82%B0%E3%83%BC)
  %7B%0A 
@@ -1466,16 +1466,17 @@
 Hand.%E3%82%B0%E3%83%BC)
+)
  %7B%0A     
@@ -1610,24 +1610,40 @@
 ce Actor
+%3CT extends Hand%3E
  %7B%0A%0A    
 Hand cho
@@ -1634,20 +1634,17 @@
  %7B%0A%0A    
-Hand
+T
  choice(
@@ -1690,105 +1690,94 @@
     
-private final Scanner scanner = new Scanner(System.in);%0A%0A    @Override%0A    public Hand choice() %7B
+@Override%0A    public Hand choice() %7B%0A        Scanner scanner = new Scanner(System.in);
 %0A   
@@ -2250,16 +2250,33 @@
  0;%0A%0A   
+ %3CT extends Hand%3E
  void de
@@ -2293,29 +2293,19 @@
 ner(
-Hand
+T
  player
-hand, Hand
+, T
  com
@@ -2309,20 +2309,16 @@
 computer
-hand
 ) %7B%0A    
@@ -2357,20 +2357,16 @@
 + player
-hand
 );%0A     
@@ -2407,20 +2407,16 @@
 computer
-hand
 );%0A     
@@ -2443,20 +2443,16 @@
 e(player
-hand
 , comput
@@ -2453,20 +2453,16 @@
 computer
-hand
 )) %7B%0A   

use Hand#equals