python面向对象完成商品销售管理系统

python面向对象完成商品销售管理系统

系统流程图:

image.png

系统功能演示:

image.png

image.png

系统代码架构:

image.png

部分代码截图:

image.png

image.png

完整代码
https://download.csdn.net/download/Deng872347348/87687181
  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
好的,我可以为你提供一个简单的商品销售管理系统Python代码实现,具体如下: ``` class Product: def __init__(self, name, price, quantity): self.name = name self.price = price self.quantity = quantity class Sales: def __init__(self): self.sales = [] def add_sale(self, product, quantity): self.sales.append((product, quantity)) def get_total_sales(self): total_sales = 0 for product, quantity in self.sales: total_sales += product.price * quantity return total_sales class Inventory: def __init__(self): self.products = [] def add_product(self, product): self.products.append(product) def get_product(self, name): for product in self.products: if product.name == name: return product return None def update_product_quantity(self, name, quantity): product = self.get_product(name) if product: product.quantity += quantity class Menu: def __init__(self): self.inventory = Inventory() self.sales = Sales() def add_product(self): name = input("Enter product name: ") price = float(input("Enter product price: ")) quantity = int(input("Enter product quantity: ")) product = Product(name, price, quantity) self.inventory.add_product(product) def sell_product(self): name = input("Enter product name: ") product = self.inventory.get_product(name) if product: quantity = int(input("Enter quantity to sell: ")) if product.quantity >= quantity: self.sales.add_sale(product, quantity) self.inventory.update_product_quantity(name, -quantity) print("Sale successful!") else: print("Not enough stock!") else: print("Product not found!") def view_inventory(self): print("\n".join([f"{product.name}: {product.quantity}" for product in self.inventory.products])) def view_sales(self): total_sales = self.sales.get_total_sales() print(f"Total sales: {total_sales}") def show_menu(self): while True: print("\n1. Add product") print("2. Sell product") print("3. View inventory") print("4. View sales") print("5. Exit") choice = input("Enter your choice: ") if choice == "1": self.add_product() elif choice == "2": self.sell_product() elif choice == "3": self.view_inventory() elif choice == "4": self.view_sales() elif choice == "5": break else: print("Invalid choice!") menu = Menu() menu.show_menu() ``` 以上代码实现了一个简单的商品销售管理系统,包括商品管理销售管理和库存管理等功能。你可以根据自己的需要进行修改和扩展。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Deng872347348

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值