狗屁不通的购物车-创新互联

#仓库类
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('没有该商品')

成都创新互联主营双滦网站建设的网络公司,主营网站建设方案,成都app开发,双滦h5微信小程序开发搭建,双滦网站营销推广欢迎双滦等地区企业咨询
    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价格:%-5s \t数量:%-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('充值成功,现在共有%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('账号密码输入错误')
            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('注册成功')
print('你的账号:\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('请充值')
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('没有对应的商品')

    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('无效参数')
#输入类
class Log():
def id(self):
ids = input('请输入id:')
return ids
def mima(self):
ma = input('请输入密码:')
return ma
def mingzi(self):
mz= input('请输入名字:')
return mz
def xuanxiang(self):
xx = input('请输入选项:')
return xx
def xuanze(self):
xz = input('请选择:')
return xz

print('欢迎光临'.center(50,'*'))
while True:
print('请选择注册或者登录')
print('1. 注册')
print('2. 登录')
log = Log()
xx = log.xuanxiang()
if xx == '1':
#注册
print('欢迎注册')
b = log.mima()
c = log.mingzi()
loggin = Logup()
logs2 =loggin.logup(b,c)
continue
elif xx == '2':
#登录
print('请先登录')
a = log.id()
b = log.mima()
loggin = Loggin(a,b)
logs = loggin.login()
if logs != None:
while True:
print('请选择选项:')
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('无效的选择。请重新选择')
                print('')
    else:
        print('请重新输入')
        input('')
else:
    print('无效的选择,请重新输入')
    input('')

另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。

新闻标题:狗屁不通的购物车-创新互联
网页网址:https://www.cdcxhl.com/article40/cddoho.html

成都网站建设公司_创新互联,为您提供营销型网站建设移动网站建设商城网站软件开发域名注册定制开发

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

商城网站建设