💻 개인공부 💻/Java

퀴즈 게임 소스(암산, 아재개그)

공대생 배기웅 2020. 1. 15. 18:15
반응형

사용한 자바 개념: //쓰레드, 예외, 스캐너, 무작위 변수,String contains 프레임워크

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
import java.util.*;
 
 
public class GoomonTest {
 
    private static int count;
 
 
    public static void main(String[] args) {
        // TODO Auto-generated method stub
    
    System.out.println("구몬 테스트 입니다");
    System.out.println("준비가 되셨으면 Enter키를 누르세요");
    Scanner scan=new Scanner(System.in);
    String enter=" ";    
    enter=scan.nextLine();
    
    System.out.println("3초 뒤에 시작합니다");
    try {
        for(int i=3; i>0;i--) {
        Thread.sleep(1000);
        System.out.println(i);
        }
    }catch(InterruptedException e) {
        e.printStackTrace();
    }
    
    calculation();
    
    
    
//===================퀴즈구간===================================================    
    System.out.println("아재개그 테스트 입니다");
    System.out.println("준비가 되셨으면 Enter키를 누르세요");
    Scanner scan1=new Scanner(System.in);
    String enter1=" ";    
    enter1=scan1.nextLine();
    
    System.out.println("3초 뒤에 시작합니다");
    
    try {
        for(int i=3; i>0;i--) {
        Thread.sleep(1000);
        System.out.println(i);
        }
    }catch(InterruptedException e) {
        e.printStackTrace();
    }
        aze();
    }
    
//===================아재드립 퀴즈구간 끝===================================================    
    
 
//=======================계산하는 구간===========================================    
        static void calculation() {
        while(count<=10) {
            
            int i=(int)(Math.random()*20)+1;
            
            int j=(int)(Math.random()*20)+1;
            
            
            System.out.println(i+"*"+j+"= ?");
            
            int answer=0;
            
            Scanner scan1=new Scanner(System.in);
            answer=scan1.nextInt();
            
            if(answer==i*j) {
                System.out.println("정답입니다");
                count++;
            }else {System.out.println("삐익~! 오답입니다");}}
        }
//==================================계산하는 구간 끝===========================================    
    
    static void aze() {
        
        System.out.println("신데렐라가 잠을 못자면?");
        Scanner scan1=new Scanner(System.in);
        String enter1=" ";    
        enter1=scan1.nextLine();
        boolean b=enter1.contains("모짜렐라");
        if(b==true) {
            System.out.println("정답입니다!");
            count++;
        }else {
            System.out.println("틀렸습니다. 정답은 "+'"'+"모짜젤라"+'"'+"입니다");
        }
//=============================================================================        
        System.out.println("경찰서의 반댓말은?");
        Scanner scan2=new Scanner(System.in);
        String enter2=" ";    
        enter2=scan1.nextLine();
        boolean b1=enter2.contains("경찰앉아");
        if(b1==true) {
            System.out.println("정답입니다!");
            count++;
        }else {
            System.out.println("틀렸습니다. 정답은 "+'"'+"경찰앉아"+'"'+"입니다");
        }
//=========================================================================        
        System.out.println("동생과 형이 싸우는데 엄마가 동생편만 드는 세상은?");
        Scanner scan3=new Scanner(System.in);
        String enter3=" ";    
        enter3=scan1.nextLine();
        boolean b2=enter3.contains("형편없는 세상");
        boolean b21=enter3.contains("형편 없는 세상");
        if(b2==true||b21==true) {
            System.out.println("정답입니다!");
            count++;
        }else {
            System.out.println("틀렸습니다. 정답은 "+'"'+"형편 없는 세상"+'"'+"입니다");
        }
//==============================================================================
        System.out.println("설탕이 깜짝 놀라면?");
        Scanner scan4=new Scanner(System.in);
        String enter4=" ";    
        enter4=scan4.nextLine();
        boolean b3=enter4.contains("이럴슈가");
        boolean b33=enter4.contains("이럴 슈가");
        boolean b31=enter4.contains("이럴수가");
        boolean b32=enter4.contains("이럴 수가");
        if(b3==true||b33==true||b32==true||b32==true) {
            System.out.println("정답입니다!");
            count++;
        }else {
            System.out.println("틀렸습니다. 정답은 "+'"'+"이럴슈가"+'"'+"입니다");
        }
        
    System.out.println("맞힌 개수는 "+count+"개 입니다");
    }
    
 
 
}
 
 
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
http://colorscripter.com/info#e" target="_blank" style="text-decoration:none;color:white">cs

 

728x90
반응형