首先,需要定义顾客类和员工类,分别包含会员卡号、姓名、性别、电话等信息和相关的对属性做操作的行为,以及编号、姓名、性别、电话、美发项目(理发、烫发、洗发)等信息和相关的对属性做操作的行为。 其次,需要定义美发类,包含各种美发项目的收费标准和相关的对属性做操作的行为。 接下来,需要定义一个管理类,实现添加、删除、修改、查询顾客信息和员工信息的功能。要求编号要唯一,如果添加了重复编号的记录时,则提示数据添加重复并取消添加。删除、修改、查询时,如果没有对应人员记录,则提示“记录为空!”并返回操作。 最后,需要使用外部文件存储相关数据,以便系统能够持久化保存数据 生成代码
时间: 2024-02-07 18:04:16 浏览: 53
以下是一个简单的美发店管理系统的代码示例,包括了顾客类、员工类、美发类和管理类的定义以及相关的操作函数。注意,此示例仅供参考,具体实现可根据需求进行修改和完善。
顾客类:
```python
class Customer:
def __init__(self, card_number, name, gender, phone):
self.card_number = card_number
self.name = name
self.gender = gender
self.phone = phone
def get_card_number(self):
return self.card_number
def set_card_number(self, card_number):
self.card_number = card_number
def get_name(self):
return self.name
def set_name(self, name):
self.name = name
def get_gender(self):
return self.gender
def set_gender(self, gender):
self.gender = gender
def get_phone(self):
return self.phone
def set_phone(self, phone):
self.phone = phone
```
员工类:
```python
class Employee:
def __init__(self, id, name, gender, phone, hairdressing):
self.id = id
self.name = name
self.gender = gender
self.phone = phone
self.hairdressing = hairdressing
def get_id(self):
return self.id
def set_id(self, id):
self.id = id
def get_name(self):
return self.name
def set_name(self, name):
self.name = name
def get_gender(self):
return self.gender
def set_gender(self, gender):
self.gender = gender
def get_phone(self):
return self.phone
def set_phone(self, phone):
self.phone = phone
def get_hairdressing(self):
return self.hairdressing
def set_hairdressing(self, hairdressing):
self.hairdressing = hairdressing
```
美发类:
```python
class Hairdressing:
def __init__(self, name, price):
self.name = name
self.price = price
def get_name(self):
return self.name
def set_name(self, name):
self.name = name
def get_price(self):
return self.price
def set_price(self, price):
self.price = price
```
管理类:
```python
class Management:
def __init__(self):
self.customers = []
self.employees = []
self.hairdressings = []
def add_customer(self, customer):
for c in self.customers:
if c.get_card_number() == customer.get_card_number():
print("添加失败,会员卡号重复!")
return
self.customers.append(customer)
print("添加成功!")
def remove_customer(self, card_number):
for c in self.customers:
if c.get_card_number() == card_number:
self.customers.remove(c)
print("删除成功!")
return
print("记录为空!")
def modify_customer(self, card_number, name, gender, phone):
for c in self.customers:
if c.get_card_number() == card_number:
c.set_name(name)
c.set_gender(gender)
c.set_phone(phone)
print("修改成功!")
return
print("记录为空!")
def query_customer(self, card_number):
for c in self.customers:
if c.get_card_number() == card_number:
print("姓名:", c.get_name())
print("性别:", c.get_gender())
print("电话:", c.get_phone())
return
print("记录为空!")
def add_employee(self, employee):
for e in self.employees:
if e.get_id() == employee.get_id():
print("添加失败,编号重复!")
return
self.employees.append(employee)
print("添加成功!")
def remove_employee(self, id):
for e in self.employees:
if e.get_id() == id:
self.employees.remove(e)
print("删除成功!")
return
print("记录为空!")
def modify_employee(self, id, name, gender, phone, hairdressing):
for e in self.employees:
if e.get_id() == id:
e.set_name(name)
e.set_gender(gender)
e.set_phone(phone)
e.set_hairdressing(hairdressing)
print("修改成功!")
return
print("记录为空!")
def query_employee(self, id):
for e in self.employees:
if e.get_id() == id:
print("姓名:", e.get_name())
print("性别:", e.get_gender())
print("电话:", e.get_phone())
print("美发项目:", e.get_hairdressing())
return
print("记录为空!")
def add_hairdressing(self, hairdressing):
for h in self.hairdressings:
if h.get_name() == hairdressing.get_name():
print("添加失败,美发项目重复!")
return
self.hairdressings.append(hairdressing)
print("添加成功!")
def remove_hairdressing(self, name):
for h in self.hairdressings:
if h.get_name() == name:
self.hairdressings.remove(h)
print("删除成功!")
return
print("记录为空!")
def modify_hairdressing(self, name, price):
for h in self.hairdressings:
if h.get_name() == name:
h.set_price(price)
print("修改成功!")
return
print("记录为空!")
def query_hairdressing(self, name):
for h in self.hairdressings:
if h.get_name() == name:
print("美发项目:", h.get_name())
print("收费标准:", h.get_price())
return
print("记录为空!")
```
使用示例:
```python
# 创建管理类实例
management = Management()
# 添加顾客
customer = Customer("001", "张三", "男", "123456789")
management.add_customer(customer)
# 添加员工
employee = Employee("001", "李四", "男", "987654321", "理发")
management.add_employee(employee)
# 添加美发项目
hairdressing = Hairdressing("洗发", 30)
management.add_hairdressing(hairdressing)
# 查询顾客信息
management.query_customer("001")
# 修改员工信息
management.modify_employee("001", "王五", "男", "135792468", "烫发")
# 删除美发项目
management.remove_hairdressing("洗发")
# 查询美发项目信息
management.query_hairdressing("烫发")
```
阅读全文