import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.IOException;

class Game{
 public static void main(String[] args) throws IOException {

  BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  
  System.out.println("가위바위보 게임시작 // 처음배팅금액 : 1000원 지급");

  int point = 1000;

  while(true){

   System.out.println("1. 주먹\n" + "2. 가위\n" + "3. 보자기\n" + "0.프로그램 종료");
   System.out.print("메뉴선택 : ");
   int user = Integer.parseInt(br.readLine());
   if(user == 0){System.out.println("게임이 종료되었습니다."); break;}

   System.out.print("배팅금액 : ");
   int money = Integer.parseInt(br.readLine());
   
   System.out.print("결과를 보시려면 Enter를 치세요 ^^  \n");
   String enter = br.readLine();

   int com = (int)(Math.random()*3)+1;
    if(user == 1){
     if(com == 2){
      System.out.println("computer : 가위, you : 주먹");
      point = point + money;
      System.out.println("You Win!!! 잔액 : "+point+"원");
     }
     else if(com == 3){
      System.out.println("computer : 보자기, you : 주먹");
      point = point - money;
      System.out.println("You Lose!!! 잔액 : "+point+"원");
     }
     else{
      System.out.println("computer : 주먹, you : 주먹");
      System.out.println("비겼다!! 잔액 : "+point+"원");
     }
    } //if end

    if(user == 2){
     if(com == 3){
      System.out.println("computer : 보자기, you : 가위");
      point = point + money;
      System.out.println("You Win!!! 잔액 : "+point+"원");
     }
     else if(com == 1){
      System.out.println("computer : 주먹, you : 가위");
      point = point - money;
      System.out.println("You Lose!!! 잔액 : "+point+"원");
     }
     else{
      System.out.println("computer : 가위, you : 가위");
      System.out.println("비겼다!! 잔액 : "+point+"원");
     }
    } //if end

    if(user == 3){
     if(com == 1){
      System.out.println("computer : 주먹, you : 보자기");
      point = point + money;
      System.out.println("You Win!!! 잔액 : "+point+"원");
     }
     else if(com == 2){
      System.out.println("computer : 가위, you : 보자기");
      point = point - money;
      System.out.println("You Lose!!! 잔액 : "+point+"원");
     }
     else{
      System.out.println("computer : 보자기, you : 보자기");
      System.out.println("비겼다!! 잔액 : "+point+"원");
     }
    } //if end


   System.out.println("\n\n");
   if(point <= 0) {System.out.print("포인트 부족. 게임이 종료되었습니다."); break; }
    

  } //while end
  
 }
} //class end

+ Recent posts