如何使用python实现手机销售管理系统

发布时间:2021-04-07 10:50:37 作者:小新
来源:亿速云 阅读:126

这篇文章将为大家详细讲解有关如何使用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.返回
 4.退出程序

具体实现其功能的代码如下:

# 数据模型类
class Phone(object):
 '''
 手机类
 '''
 def __init__(self,name,price,count):
  self.name = name
  self.price = price
  self.count = count
 
# 用来操作整个程序执行逻辑
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
  phone.count = new_count
 
 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
   else:
    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.price,phone.count)
 
 def change(self):
  for phone in self.phones:
   print(phone.name,phone.price,phone.count)
 
  print('* 1.添加新产品')
  print('* 2.修改原有产品')
  result = int(input('* 请选择您的操作:'))
  while result < 1 or result > 2:
   result = (input('* 选项不存在,请重新选择:'))
  if result == 1:
   self.qurey_all()
  else:
   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()

程序运行出来之后的界面如下:

如何使用python实现手机销售管理系统

然后根据提示继续操作

关于“如何使用python实现手机销售管理系统”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,使各位可以学到更多知识,如果觉得文章不错,请把它分享出去让更多的人看到。

推荐阅读:
  1. 基于JSP销售管理系统的项目设计定做
  2. Python基础项目:超市商品销售管理系统

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

python

上一篇:怎么使用Python实现查找字符串数组最长公共前缀

下一篇:如何使用python实现字符串加密生成唯一固定长度字符串

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》