请帮我生成一个代码:宠物网店系统能为人们提供更为便捷、更为满意的宠物服务。宠物网店管理平台是一套专门为宠物店设计的管理软件。该软件结合宠物店的日常管理需求,包括宠物用品销售、宠物美容、宠物医疗、宠物寄养、宠物交易、会员管理等多种业务管理。
时间: 2023-07-10 15:05:47 浏览: 204
以下是一个简单的宠物网店系统代码示例:
```python
class PetStore:
def __init__(self):
self.products = []
self.services = []
self.members = []
self.sales = []
def add_product(self, product):
self.products.append(product)
def add_service(self, service):
self.services.append(service)
def add_member(self, member):
self.members.append(member)
def make_sale(self, sale):
self.sales.append(sale)
class Product:
def __init__(self, name, price, quantity):
self.name = name
self.price = price
self.quantity = quantity
def __str__(self):
return "{} ({}): ${}".format(self.name, self.quantity, self.price)
class Service:
def __init__(self, name, price, duration):
self.name = name
self.price = price
self.duration = duration
def __str__(self):
return "{} ({} mins): ${}".format(self.name, self.duration, self.price)
class Member:
def __init__(self, name, email, phone):
self.name = name
self.email = email
self.phone = phone
class Sale:
def __init__(self, product, service, member):
self.product = product
self.service = service
self.member = member
self.total_price = product.price + service.price
def __str__(self):
return "{} bought {} and received {} for a total of ${}".format(self.member.name, self.product.name, self.service.name, self.total_price)
# Example usage
store = PetStore()
# Add products
food = Product("Pet food", 10.99, 50)
toys = Product("Pet toys", 5.99, 100)
store.add_product(food)
store.add_product(toys)
# Add services
groom = Service("Pet grooming", 35.99, 60)
board = Service("Pet boarding", 25.99, 1440)
store.add_service(groom)
store.add_service(board)
# Add members
john = Member("John", "john@example.com", "555-1234")
jane = Member("Jane", "jane@example.com", "555-5678")
store.add_member(john)
store.add_member(jane)
# Make a sale
sale = Sale(food, groom, john)
store.make_sale(sale)
# Print sales
for s in store.sales:
print(s)
```
该代码实现了一个基本的宠物网店系统,其中包括了商品、服务、会员和销售等模块,可以根据需要进行扩展。
阅读全文