帮我写一个用python代码的影碟租赁管理信息系统,可以实现影碟管理、影碟租借、 影碟查询和月租管理的功能。
时间: 2024-04-08 15:33:39 浏览: 21
当然可以帮你写一个用Python的影碟租赁管理信息系统,实现影碟管理、影碟租借、影碟查询和月租管理的功能。下面是一个简单的示例代码:
```python
class DVD:
def __init__(self, title, actor, release_date):
self.title = title
self.actor = actor
self.release_date = release_date
class DVDManagementSystem:
def __init__(self):
self.dvds = []
self.rented_dvds = []
self.users = []
def add_dvd(self, dvd):
self.dvds.append(dvd)
def delete_dvd(self, dvd):
if dvd in self.dvds:
self.dvds.remove(dvd)
def rent_dvd(self, user, dvd):
if dvd in self.dvds and dvd not in self.rented_dvds:
self.rented_dvds.append(dvd)
user.rented_dvds.append(dvd)
def return_dvd(self, user, dvd):
if dvd in self.rented_dvds and dvd in user.rented_dvds:
self.rented_dvds.remove(dvd)
user.rented_dvds.remove(dvd)
def search_dvds_by_title(self, title):
found_dvds = []
for dvd in self.dvds:
if title.lower() in dvd.title.lower():
found_dvds.append(dvd)
return found_dvds
def search_dvds_by_actor(self, actor):
found_dvds = []
for dvd in self.dvds:
if actor.lower() in dvd.actor.lower():
found_dvds.append(dvd)
return found_dvds
def search_dvds_by_date(self, release_date):
found_dvds = []
for dvd in self.dvds:
if release_date == dvd.release_date:
found_dvds.append(dvd)
return found_dvds
def add_user(self, user):
self.users.append(user)
def get_premium_users(self):
premium_users = []
for user in self.users:
if user.user_type == "Premium":
premium_users.append(user)
return premium_users
class User:
def __init__(self, username, password, user_type):
self.username = username
self.password = password
self.user_type = user_type
self.rented_dvds = []
# 使用示例
system = DVDManagementSystem()
# 影碟管理
dvd1 = DVD("影片1", "演员1", "2022-01-01")
dvd2 = DVD("影片2", "演员2", "2022-02-01")
system.add_dvd(dvd1)
system.add_dvd(dvd2)
system.delete_dvd(dvd2)
# 影碟租借
user1 = User("user1", "password1", "Premium")
user2 = User("user2", "password2", "Regular")
system.add_user(user1)
system.add_user(user2)
system.rent_dvd(user1, dvd1)
system.return_dvd(user1, dvd1)
# 影碟查询
dvds_by_title = system.search_dvds_by_title("影片")
dvds_by_actor = system.search_dvds_by_actor("演员")
dvds_by_date = system.search_dvds_by_date("2022-01-01")
# 月租管理
premium_users = system.get_premium_users()
```
这是一个简单的示例代码,你可以根据你的具体需求进行修改和扩展。例如,你可以添加数据库连接和SQL查询来实现数据的持久化存储。同时,你还可以添加更多的功能和逻辑来完善影碟租赁管理信息系统。
相关推荐
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![7z](https://img-home.csdnimg.cn/images/20210720083312.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)