import random
# 목적지(destination)
des_x = random.randint(-10, 10)
des_y = random.randint(-10, 10)
# 현재 위치
x = 0
y = 0
# 방향(direction)
direc = 0
# 속도
speed = 0
# 요금
fee = 0
# 이동 칸 수
count = 0
run = True
while run:
print("--- T A X I ---")
print("목적지 :", des_x, des_y)
print("현위치 :", x, y)
print("방 향 :", direc)
print("속 도 :", speed)
print("1.방향설정")
print("2.속도설정")
print("3.이동하기")
choice = int(input("메뉴 선택 : "))
if choice == 1:
direc = int(input("1)동 2)서 3)남 4)북 \n입력 : "))
elif choice == 2:
speed = int(input("속도 입력(1~3) : "))
elif choice == 3:
if direc == 1:
x = x + speed
elif direc == 2:
x = x - speed
elif direc == 3:
y = y + speed
elif direc == 4:
y = y - speed
count = count + speed
if des_x == x and des_y == y:
print("---------------")
print("목적지에 도착하였습니다.")
run = False
fee = count // 2 * 50
if count % 2 != 0:
fee = fee + 50
print("요금 =", fee)
댓글