写一个基于python的宿舍管理系统
时间: 2024-05-14 22:17:15 浏览: 121
好的,宿舍管理系统主要包括以下功能:
1. 学生信息管理:包括学生姓名、学号、班级、性别等信息的录入和查询。
2. 宿舍信息管理:包括宿舍号、宿舍楼、宿舍类型、宿舍费用等信息的录入和查询。
3. 入住管理:包括学生入住宿舍的登记、退宿手续等。
4. 维修管理:包括宿舍维修申报、维修进度查询等。
5. 费用管理:包括宿舍费用的收取和查询等。
下面是一个基于Python的宿舍管理系统的简单实现:
```python
# 学生信息类
class Student:
def __init__(self, name, id, class_name, gender):
self.name = name
self.id = id
self.class_name = class_name
self.gender = gender
# 宿舍信息类
class Dormitory:
def __init__(self, number, building, type, cost):
self.number = number
self.building = building
self.type = type
self.cost = cost
# 宿舍管理系统类
class DormitoryManagementSystem:
def __init__(self):
self.students = []
self.dormitories = []
self.check_ins = []
# 学生信息管理
def add_student(self, name, id, class_name, gender):
student = Student(name, id, class_name, gender)
self.students.append(student)
def search_student(self, id):
for student in self.students:
if student.id == id:
return student
return None
# 宿舍信息管理
def add_dormitory(self, number, building, type, cost):
dormitory = Dormitory(number, building, type, cost)
self.dormitories.append(dormitory)
def search_dormitory(self, number):
for dormitory in self.dormitories:
if dormitory.number == number:
return dormitory
return None
# 入住管理
def check_in(self, id, number):
student = self.search_student(id)
dormitory = self.search_dormitory(number)
if student and dormitory:
self.check_ins.append((student, dormitory))
return True
else:
return False
def check_out(self, id, number):
for check_in in self.check_ins:
if check_in[0].id == id and check_in[1].number == number:
self.check_ins.remove(check_in)
return True
return False
# 维修管理
def report_repair(self, number):
dormitory = self.search_dormitory(number)
if dormitory:
dormitory.repair = True
return True
else:
return False
def query_repair(self, number):
dormitory = self.search_dormitory(number)
if dormitory and dormitory.repair:
return True
else:
return False
# 费用管理
def charge_cost(self, number, cost):
dormitory = self.search_dormitory(number)
if dormitory:
dormitory.cost += cost
return True
else:
return False
def query_cost(self, number):
dormitory = self.search_dormitory(number)
if dormitory:
return dormitory.cost
else:
return None
```
以上是一个简单的宿舍管理系统的Python实现,可以根据需要进行扩展和完善。
阅读全文