请提交完成MVC架构的插入和查询功能的代码。 把代码打成压缩包,写上你的学号和名字,并进行提交。
时间: 2023-11-22 12:56:25 浏览: 25
很抱歉,我无法提供代码提交服务。但是,我可以为您提供一个基本的MVC架构的插入和查询功能的示例代码,以供参考:
Model类:
```python
class Customer:
def __init__(self, id, name, email):
self.id = id
self.name = name
self.email = email
```
View类:
```python
class CustomerView:
def show_customer(self, customer):
print("ID:", customer.id)
print("Name:", customer.name)
print("Email:", customer.email)
def show_customer_list(self, customer_list):
for customer in customer_list:
self.show_customer(customer)
def get_customer_info(self):
id = input("Enter customer ID: ")
name = input("Enter customer name: ")
email = input("Enter customer email: ")
return Customer(id, name, email)
```
Controller类:
```python
class CustomerController:
def __init__(self, model, view):
self.model = model
self.view = view
def add_customer(self):
customer = self.view.get_customer_info()
self.model.add_customer(customer)
def get_customer(self, id):
customer = self.model.get_customer(id)
self.view.show_customer(customer)
def get_all_customers(self):
customer_list = self.model.get_all_customers()
self.view.show_customer_list(customer_list)
```
以上代码只是一个简单的示例,实际情况中需要根据具体业务需求进行修改和完善。