ํ‹ฐ์Šคํ† ๋ฆฌ ๋ทฐ

package study;
import javax.swing.*;

public class SwingTest {
 public static void main(String[] ar) {
  int answer = (int) (Math.random() * 10 ) + 1;
  int input =0 ;
  String temp = "";
  int count  = 0 ;
  int limitCnt = 5;
 
  do {
   count++;
   
   temp = JOptionPane.showInputDialog("1~10๊นŒ์ง€์˜ ์ˆซ์ž๋ฅผ ์ž…๋ ฅํ•˜์‹œ์˜ค ๊ธฐํšŒ๋Š” 5" + " ๋๋‚ด๋ ค๋ฉด -1์„ ์ž…๋ ฅํ•˜์„ธ์š”.");
   
   if(temp == null || temp.equals("-1")) break;
   
   System.out.println("์ž…๋ ฅ๊ฐ’ : " + temp);
   
   input = Integer.parseInt(temp);
   
   if (answer != input) {
    System.out.println("ํ‹€๋ ธ์Šต๋‹ˆ๋‹ค. ๋‚จ์€๊ธฐํšŒ๋Š” " + (limitCnt - count) + "์ž…๋‹ˆ๋‹ค.");
    System.out.println("์ •๋‹ต์€ ? " + answer);
   } else {
    System.out.println("๋งž์ท„์Šต๋‹ˆ๋‹ค. ์ถ•ํ•˜ํ•ด์š”");
   }
   
  } while (count != limitCnt);
 }
}

๋Œ“๊ธ€