-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBomb.py
More file actions
35 lines (30 loc) · 753 Bytes
/
Bomb.py
File metadata and controls
35 lines (30 loc) · 753 Bytes
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
import random
import sys
import threading
import time
class Bomb(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
# 변수명 앞에 __ 를 붙이게 되면 private하게 사용 가능
self.__life = random.randint(1, 2)
self.__state = False
def run(self):
for i in range(10, 0, -1):
if self.__state: break;
print(i)
time.sleep(0.5)
if not self.__state: print("꼬ㅏㅇ~!!")
sys.exit()
def choose(self, line):
try:
line = int(line)
except:
line = 1
print(f'{line}을 선택하셨습니다.')
if (self.__life == line):
print('휴~ 살았다!')
else:
print('Bomb~!')
self.__state = True
def __str__(self):
return "폭탄"