python做⼀个销售管理系统_python实现⼿机销售管理系统本⽂实例为⼤家分享了python实现⼿机销售管理系统的具体代码,供⼤家参考,具体内容如下
要求如下:
⼿机销售系统
vivoX9 2798 25
iphone7(32G) 4888 31
iphone7(128G) 5668 22
iphone7P(128G) 6616 29
iphone6(16G) 3858 14
...
功能要求:
四个选项:
炸薯条机1.查看所有⼿机品牌
1.vivoX9
2.iphone7(32G)
......
分⽀选项:
1.选择产品序号查看详情(根据序号输出产品名称,价格,库存) 1.购买(库存数量-1,库存为0时,删除该产品)
2.返回
2.返回
2.更改产品库存信息
1.添加新产品(添加新产品,包括产品名称、价格、库存)
2.修改原有产品
输出所有产品信息
1.根据选择序号进⾏修改
2.返回
3.移除产品库存信息
1.查看所有产品,根据序号移除
2.移除所有产品
3.返回
具体实现其功能的代码如下:
# 数据模型类
class Phone(object):
'''
⼿机类
'''
def __init__(self,name,price,count):
self.name = name
self.price = price
# ⽤来操作整个程序执⾏逻辑
class PhoneShop(object):
'''
商店类
'''
烟饼def __init__(self):
# phone1存储所有⼿机对象
self.phones = []
def buy_phone(self):
print('* 请输⼊产品信息:')
name = print('* 请输⼊⼿机名称:')
price = print('* 请输⼊⼿机价格:')
count = print('* 请输⼊⼿机库存:')
# 创建⼀个新的phone对象
phone = Phone(name=name, price=price, count=count) # 将phone对象添加到phones列表中
self.phones.append(phone)
print(self.phones)
print('* 选择产品序号查看详情')
print('* 1.购买')
print('* 2.返回')
shop = int(input('* 请选择您的操作:'))
while shop < 1 or shop > 2:
shop = int(input('* 选项不存在,请重新选择:'))
if shop == 1:
print('* 购买成功!')
else:
pass
def xiugia(self):
self.query_all()
idx = int(input('* 请输⼊你要修改的序号:')) phone = Phone[idx - 1]
new_name = input('* 请输⼊修改的名称:') new_price = input('* 请输⼊修改的价格:') new_count = input('* 请输⼊修改的库存:') phone.name = new_name
phone.price = new_price
def run(self):
'''
超强电磁铁启动程序
:return:None
'''
while True:
print('* 欢迎使⽤⼿机销售管理系统')
print('* 1.查看所有')
print('* 2.添加⼿机')
print('* 3.删除⼿机')
print('* 4.退出程序')
select = int(input('* 请选择您的操作:')) while select < 1 or select > 4:
select = int(input('* 选项不存在,请重选:')) if select == 1:
self.change()
elif select == 2:
# 调⽤添加⼿机函数
self.buy_phone()
elif select == 3:
pass
print('* 感谢您的使⽤,欢迎下次再来!')
break
def yichu(self):
print('* 1.根据序号移除')
print('* 2.移除所有产品')
print('* 3.返回')
a = int(input('* 请选择您的操作:'))
while a <1 or a > 3:
a = int(input('* 选项不存在,请重选'))
if a == 1:
pass
elif a == 2:
is_del = int(input('* 是否移除所有产品?y/n:')) if is_del == 'y':
玻尿酸蚕丝面膜
phone_list.pop()
print('* 删除成功!')
else:
用户行为分析系统
return
else:
return
def query_all(self):
for phone in self.phones:
print(phone.name,phone.unt) def change(self):
for phone in self.phones:镀锌光亮剂
print(phone.name,phone.unt) print('* 1.添加新产品')
print('* 2.修改原有产品')
result = int(input('* 请选择您的操作:'))
while result < 1 or result > 2:
result = (input('* 选项不存在,请重新选择:')) if result == 1:
self.qurey_all()
print('* 输出所有产品信息')
print('* 1.根据选择序号进⾏修改')
print('* 2.返回')
index = int(input('* 请输⼊您的选择:'))
while index < 1 or index > 2:
index = int(input('* 选项不存在,请重新选择:'))
if index == 1:
pass
else:
return
phone_list = []
shop = PhoneShop()
shop.run()
shop.yichu()
程序运⾏出来之后的界⾯如下:
然后根据提⽰继续操作
以上就是本⽂的全部内容,希望对⼤家的学习有所帮助,也希望⼤家多多⽀持脚本之家。