狗屁不通的購物車-創(chuàng)新互聯(lián)

#倉庫類
class Repository():
l = {'屠戮之刃':[3900,20],
'無影劍-艾雷諾':[3788,22],
'子午×××劍':[3899,19],
'劍神梁月的鈍劍':[3688,22]}
def add(self, one):
if list(one.name.keys())[0] not in Repository.l:
Repository.l[list(one.name.keys())[0]] = list(one.name.values())
else:
a = one.name
b = list(a.keys())[0]
Repository.l[b][-1] += 1
print('完成')
def sub(self, one):
if list(one.name.keys())[0] not in Repository.l:
print('沒有該商品')

成都創(chuàng)新互聯(lián)主營(yíng)雙灤網(wǎng)站建設(shè)的網(wǎng)絡(luò)公司,主營(yíng)網(wǎng)站建設(shè)方案,成都app開發(fā),雙灤h5微信小程序開發(fā)搭建,雙灤網(wǎng)站營(yíng)銷推廣歡迎雙灤等地區(qū)企業(yè)咨詢
    elif list(one.name.keys())[0] == 1:
        Repository.l.remove(one.name)
    else:
        a = one.name
        b = list(a.keys())[0]
        Repository.l[b][-1] -= 1
        print()

def show(self):
    n = 0
    for i,k in Repository.l.items():
        n += 1
        print('%d 商品:%-14s\t價(jià)格:%-5s \t數(shù)量:%-3s' % (n,i, k[0],k[-1]))

class Commdity(Repository):
def init(self, name = None, price = None, count = None):
self.name = name
self.price = price
self.count = count

def shop(self):
    return Repository.l

#用戶類
class Customer():
sala =50000
def chongzhi(self, money):
Customer.sala = Customer.sala + int(money)
print('充值成功,現(xiàn)在共有%s元' % self.sala)

#登錄類
class Loggin(Customer):
ls = {('1','2'):3}
def init(self, cid, pwd, name = None):
self.cid = cid
self.pwd = pwd
self.name = name

def login(self):
        if (self.cid, self.pwd) in list(Loggin.ls.keys()):
            print('登錄成功')
            return Loggin(self.cid,self.name, self.pwd)

        else:
            print('賬號(hào)密碼輸入錯(cuò)誤')
            return

class Logup():
def logup(self, pwd, name):
import random
while True:
cids = random.randint(10000,99999)
if cids not in Loggin.ls:
Loggin.ls[str(cids),pwd] = name
print('注冊(cè)成功')
print('你的賬號(hào):\nid:%-10s\n密碼:%-10s\n 名字:%-10s' % (cids,pwd,name))
break
else:
continue

#購物車
class Shopcar(Customer):
l = {}
def add(self, one):
if Customer.sala <= list(one.name.values())[0][0]:
print('請(qǐng)充值')
else:
if list(one.name.keys())[0] not in Shopcar.l:
print('yes')
Shopcar.l[list(one.name.keys())[0]] = list(one.name.values())[0]
Customer.sala -= list(one.name.values())[0][0]
print('購買完成,你的商品都有%s,余額:%s元' % (Shopcar.l,Customer.sala) )

        else:
            print(Shopcar.l[list(one.name.keys())[0]])
            Shopcar.l[list(one.name.keys())[0]][-1] += 1
            Customer.sala -= list(one.name.values())[0][0]

            print('購買完成,你的商品都有%s,余額:%s元' % (Shopcar.l,Customer.sala) )
def sub(self, one):
    if list(one.name.keys())[0] not in Shopcar.l:
        print('沒有對(duì)應(yīng)的商品')

    elif Shopcar.l[list(one.name.keys())[0]][-1] == 1:
        Shopcar.l.remove(list(one.name.keys())[0])
        Customer.sala += list(one.name.values())[0][0]
        print('移除成功,你的商品都有%s,余額:%s元' % (Shopcar.l,Customer.sala) )
    else:
        Shopcar.l[list(one.name.keys())[0]][-1] -= 1
        Customer.sala += list(one.name.values())[0][0]
        print('移除成功,你的商品都有%s,余額:%s元' % (Shopcar.l,Customer.sala) )

#裝備接口類
class Someequ():
def init(self, name):
self.name = name
def out_equ(self):
return self.name

#接口類
class Io():
def trans(self, inputs, choices):
if choices == '1':
return {'屠戮之刃':[3900,0]}
elif choices == '2':
return {'無影劍-艾雷諾':[3788,0]}
elif choices == '3':
return {'子午×××劍':[3899,0]}
elif choices == '4':
return { '劍神梁月的鈍劍':[3688,0]}
else:
print('無效參數(shù)')
#輸入類
class Log():
def id(self):
ids = input('請(qǐng)輸入id:')
return ids
def mima(self):
ma = input('請(qǐng)輸入密碼:')
return ma
def mingzi(self):
mz= input('請(qǐng)輸入名字:')
return mz
def xuanxiang(self):
xx = input('請(qǐng)輸入選項(xiàng):')
return xx
def xuanze(self):
xz = input('請(qǐng)選擇:')
return xz

print('歡迎光臨'.center(50,'*'))
while True:
print('請(qǐng)選擇注冊(cè)或者登錄')
print('1. 注冊(cè)')
print('2. 登錄')
log = Log()
xx = log.xuanxiang()
if xx == '1':
#注冊(cè)
print('歡迎注冊(cè)')
b = log.mima()
c = log.mingzi()
loggin = Logup()
logs2 =loggin.logup(b,c)
continue
elif xx == '2':
#登錄
print('請(qǐng)先登錄')
a = log.id()
b = log.mima()
loggin = Loggin(a,b)
logs = loggin.login()
if logs != None:
while True:
print('請(qǐng)選擇選項(xiàng):')
print('1.充值')
print('2.購買商品 ')
print('3.移除商品')
print('4.退出')
log = Log()
xx = log.xuanxiang()
if xx == '1':
#充值
log = Log()
xz = log.xuanze()
chongzhi = Customer()
chongzhi.chongzhi(xz)

            elif xx == '2':
                #購買
                commdity = Commdity()
                shoplist = commdity.shop()
                repository = Repository()
                repository.show()
                log = Log()
                xz = log.xuanze()
                io = Io()
                ios = io.trans(shoplist,xz)
                pack_equ = Someequ(ios)
                shopcar = Shopcar()
                shopcar.add(pack_equ)
                repository.sub(pack_equ)
            elif xx == '3':
                #移除
                commdity = Commdity()
                shoplist = commdity.shop()
                repository = Repository()
                repository.show()
                log = Log()
                xz = log.xuanze()
                io = Io()
                ios = io.trans(shoplist,xz)
                pack_equ = Someequ(ios)
                shopcar = Shopcar()
                shopcar.sub(pack_equ)
                repository.add(pack_equ)

            elif xx == '4':
                #退出
                print('歡迎下次光臨')
                exit()
            else:
                print('無效的選擇。請(qǐng)重新選擇')
                print('')
    else:
        print('請(qǐng)重新輸入')
        input('')
else:
    print('無效的選擇,請(qǐng)重新輸入')
    input('')

另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。

新聞標(biāo)題:狗屁不通的購物車-創(chuàng)新互聯(lián)
網(wǎng)頁網(wǎng)址:http://muchs.cn/article40/cddoho.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供營(yíng)銷型網(wǎng)站建設(shè)、移動(dòng)網(wǎng)站建設(shè)、商城網(wǎng)站、軟件開發(fā)、域名注冊(cè)、定制開發(fā)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

商城網(wǎng)站建設(shè)