-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproject.py
More file actions
151 lines (117 loc) · 3.61 KB
/
project.py
File metadata and controls
151 lines (117 loc) · 3.61 KB
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
142
143
144
145
146
147
148
149
150
151
UserTable = []
# 유저 정의
'''
User = {
'Name' : '',
'Id' : '',
'Pass' : '',
'BuyList' : [],
}
'''
ItemList = [
'A상품',
'B상품',
'C상품',
'D상품',
'E상품',
]
def CheckItemList( LoginIdx ):
print("/****************************/")
print(" [로그인]%s님 반갑습니다 " % (UserTable[LoginIdx].get('Name')))
print("/****************************/")
print('장바구니 목록 :')
for item in UserTable[LoginIdx].get('BuyList') :
print(item)
def BuyItem( LoginIdx ):
print("/****************************/")
print(" [로그인]%s님 반갑습니다 " % (UserTable[LoginIdx].get('Name')))
print("/****************************/")
for idx, item in enumerate(ItemList) :
print('%d : %s' % (idx, item))
print('구매 : ', end="")
buying = int(input())
if buying >= 0 and buying <= 5:
UserTable[LoginIdx]['BuyList'].append( ItemList[buying] )
else :
print('없는 상품입니다')
def AfterLogin( LoginIdx ):
while True:
print("/****************************/")
print(" [로그인]%s님 반갑습니다 " % (UserTable[LoginIdx].get('Name')))
print("/****************************/")
print("1. 장바구니 확인")
print("2. 상품 장바구니에 넣기")
print("3. 돌아가기")
selection = int(input())
if selection == 1 :
CheckItemList(LoginIdx)
elif selection == 2 :
BuyItem(LoginIdx)
else:
return
def UserRegister():
print("이름 : ", end="")
NAME = input()
print("아이디 : ", end="")
ID = input()
print("패스워드 : ", end="")
PASS = input()
print("패스워드 확인 : ", end="")
PASS_CONFIRM = input()
if PASS_CONFIRM != PASS:
print("패스워드가 다릅니다")
return
newUser = {
'Name': '',
'Id': '',
'Pass': '',
'BuyList': [],
}
newUser['Name'] = NAME
newUser['Id'] = ID
newUser['Pass'] = PASS
UserTable.append(newUser)
def CheckUserList():
for user in UserTable:
print("[ 이름 : %s, 아이디 : %s, 비밀번호 : %s ]" % (user['Name'], user['Id'], user['Pass']))
def UserLogIn():
print("아이디 : ", end="")
ID = input()
print("패스워드 : ", end="")
PASS = input()
LogIn_idx = -1
for idx, user in enumerate(UserTable):
if user.get('Id') == ID and user.get('Pass') == PASS :
LogIn_idx = idx
if LogIn_idx == -1 :
print('아이디와 비밀번호가 맞지 않습니다')
else :
AfterLogin(LogIn_idx)
def ProgramStart():
while True :
print("/****************************/")
print(" 쇼핑몰 프로그램 ")
print("/****************************/")
print("1. 회원 가입")
print("2. 회원 리스트 확인")
print("3. 회원 로그인")
print("커맨드 : ", end="")
selection = int(input())
if selection == 1:
UserRegister()
elif selection == 2:
CheckUserList()
elif selection == 3:
UserLogIn()
def ProgramOutLine():
print("안녕하세요 파이썬 첫 프로젝트입니다")
print("프로젝트 개요 : 쇼핑몰 프로그램 ")
print("프로젝트 기능 :")
print("1. 회원 가입")
print("2. 회원 로그인")
print("3. 회원 로그인 후 상품 구매")
print("4. 회원 로그인 후 장바구니 확인")
ProgramOutLine()
ProgramStart()
week-1.py
week-1.py 표시 중입니다.