目录表
-
- 1 需求分析
- **主函数:调用创建的各种类和方法**
- 交易类:
- 交易的实现
- 房屋类:主要管理房屋信息
- 房主信息:管理房屋主人的信息
- 房主的实现:
- 看房信息:存储有人想去实地看房的信息,预约等
- 看房信息的实现:
- 员工信息:存储中介公司的员工信息
- 员工信息类的实现:
- 租房者的信息类:租房者想要租房等功能的实现
- 租房者的实现
- 总结
- 房屋中介公司需要对日常工作中涉及到的房屋、房主和租房顾客等各类数据进行有效地管理,以实现业务的自动化,提高运行效率的同时也能够降低人力成本。本设计主要针对房屋中介公司建立一个简单应用系统。
1 需求分析
房屋中间管理系统主要的是:
(1)房主能够发布房屋信息,并能够对房屋信息进行修改和删除;
(2)租房顾客能够查询房屋信息,请求看房,并确定租房完成租房交易。
话不多说直接上代码:
主函数:调用创建的各种类和方法
#include"deal.h"
#include"house.h"
#include"house_owner.h"
#include"look_house.h"
#include"staff.h"
#include"tenant.h"
#include
#include
#include
#include
#include
#include
#include
static int kk = 100;
using namespace std;
class customer_information :public house_owner, public tenant { //派生租房者类及房主类的子类
public:
void display() { //输出客户信息
dis_information();
cout endl endl;
dis_tenant();
}
bool find(string a,char *b); //判断登录密码是否正确
void amend(); //修改密码
};
bool customer_information::find(string a,char *b) { //判断用户登录密码是否正确
if (findt(a, b,0) || findh(a, b,0)) {
return true;
}
else return false;
}
void customer_information::amend() { //修改用户密码
system("cls");
string a;
char b[20];;
cout "请输入你的用户名:"; cin >> a;
cout "请输入你的原密码:"; cin >> b;
customer_information s;
while (!s.find(a, b)) {
cout "用户名或密码错误!" endl;
cout "请重新输入用户名:"; cin >> a;
cout "请重新输入密码:"; cin >> b;
}
cout "请输入你要修改的密码:"; cin >> b;
if (s.findh(a, b, 1) || s.findt(a, b, 1)) {
cout "修改成功!" endl;
}
system("pause");
}
void code_file_Read() { //设置系统使用者密码,第一次使用系统时设置,录入第一位管理者
char code[20];
char temp[20];
ifstream fin("code.dat");
system("cls");
int k = 0;
while (fin >> code) {
k++;
}
if (k == 0) {
cout "检测到第一次使用系统,请先设置系统密码:";
ofstream fout("code.dat");
if (!fout) {
cout "打开code.dat文件失败!" endl;
abort();
}
cin >> code;
fout code "n"; //写入密码文件
cout "密码设置成功!" endl;
system("pause");
fin.close();
fout.close();
return;
}
fin.close();
}
void code_file_delete(){ //修改系统管理者密码
char code[20];
char temp[20];
ifstream fin("code.dat");
if (!fin) {
cout "打开文件code.dat失败!" endl;
abort();
}
fin >> code;
cout "请输入原密码:";
do {
cin >> temp;
if (strcmp(temp, code) == 0) {
ofstream fout("code.dat");
if (!fout) {
cout "打开code.dat文件失败!" endl;
abort();
}
cout "请输入新密码:";
cin >> code;
fout code "n";
cout "设置成功!";
fin.close();
fout.close();
system("pause");
return;
}
else {
cout "密码错误,请重新输入原密码:";
cin >> temp;
}
} while (1);
}
int main_menu() { //管理员登录之后界面
int chioce;
system("cls");
cout "1:客户管理n";
cout "2:房源管理n";
cout "3:员工管理n";
cout "4:查看交易信息n";
cout "5:修改密码n";
cout "6.查看佣金n";
cout "7.看房信息管理n";
cout "0:退出n";
cout "请输入选择:";
cin >> chioce;
while (chioce 0 || chioce>7) {
cout "请重新选择:";
cin >> chioce;
}
return chioce;
}
void add_customer() { //添加客户信息
int chioce;
house_owner s1;
tenant s;
do {
system("cls");
cout "1.添加租房者客户信息" endl;
cout "2.添加房主客户信息" endl;
cout "0.返回" endl;
cout "请输入你的选择:";
cin >> chioce;
while (chioce > 2 || chioce 0) {
cout "请重新输入你的选择:" endl;
cin >> chioce;
}
switch (chioce) {
case 1:
s.get_tenant();
break;
case 2:
s1.get_information();
break;
case 0:
break;
}
} while (chioce != 0);
system("pause");
}
void delete_customer() { //删除客户信息
int chioce;
tenant s;
house_owner s1;
do {
system("cls");
cout "1.删除租房者客户信息" endl;
cout "2.删除房主客户信息" endl;
cout "0.返回" endl;
cout "请输入你的选择:";
cin >> chioce;
while (chioce > 2 || chioce 0) {
cout "请重新输入你的选择:" endl;
cin >> chioce;
}
switch (chioce) {
case 1:
s.delete_tenant();
break;
case 2:
s1.delete_information();
break;
case 0:
break;
}
system("pause");
} while (chioce != 0);
}
void modify_customer() { //修改客户信息
int chioce;
tenant s;
house_owner s1;
do {
system("cls");
cout "1.修改租房者客户信息" endl;
cout "2.修改房主客户信息" endl;
cout "0.返回" endl;
cout "请输入你的选择:";
cin >> chioce;
while (chioce > 2 || chioce 0) {
cout "请重新输入你的选择:" endl;
cin >> chioce;
}
switch (chioce) {
case 1:
s.amend_tenant();
break;
case 2:
s1.amend_information();
break;
}
system("pause");
} while (chioce != 0);
}
void query_customer() { //查询客户信息
int chioce;
tenant s;
house_owner s1;
do {
system("cls");
cout "1.查询租房者客户信息" endl;
cout "2.查询房主客户信息" endl;
cout "0.返回" endl;
cout "请输入你的选择:";
cin >> chioce;
while (chioce > 2 || chioce 0) {
cout "请重新输入你的选择:" endl;
cin >> chioce;
}
switch (chioce) {
case 1:
s.find_tenant();
break;
case 2:
s1.find_information();
break;
case 0:
break;
}
} while (chioce != 0);
}
int Customer_management() { //管理客户的功能函数
int chioce;
customer_information s;
do {
system("cls");
cout "1.显示客户信息" endl;
cout "2.添加客户" endl;
cout "3.删除客户" endl;
cout "4.修改客户信息" endl;
cout "5.查询客户信息" endl;
cout "0.返回" endl;
cout "请输入你的选择:";
cin >> chioce;
while (chioce 0 || chioce>5) {
cout "请重新选择:";
cin >> chioce;
}
switch (chioce) {
case 1:
s.display();
break;
case 2:
add_customer();
break;
case 3:
delete_customer();
break;
case 4:
modify_customer();
break;
case 5:
query_customer();
break;
case 0:
break;
}
} while (chioce != 0);
return chioce;
}
void housing_management() { //房源管理信息
int chioce;
house s;
do {
system("cls");
cout "1.显示房屋信息" endl;
cout "2.添加房屋信息" endl;
cout "3.删除房屋信息" endl;
cout "4.修改房屋信息" endl;
cout "5.查询房屋信息" endl;
cout "0.返回" endl;
cout "请输入你的选择:";
cin >> chioce;
while (chioce 0 || chioce>5) {
cout "请重新输入你的选择:";
cin >> chioce;
}
switch (chioce) {
case 1:
s.dis_house();
break;
case 2:
s.get_house();
break;
case 3:
s.delete_house();
break;
case 4:
s.amend_house();
break;
case 5:
s.find_house();
break;
case 0: break;
}
} while (chioce != 0);
}
void staff_management() { //员工信息管理界面
int chioce;
staff s;
do {
system("cls");
cout "1.显示员工信息" endl;
cout "2.添加员工信息" endl;
cout "3.删除员工信息" endl;
cout "4.修改员工信息" endl;
cout "5.查询员工信息" endl;
cout "0.返回" endl;
cout "请输入你的选择:";
cin >> chioce;
while (chioce 0 || chioce>5) {
cout "请重新输入你的选择:";
cin >> chioce;
}
switch (chioce) {
case 1:
s.dis_staff();
break;
case 2:
s.get_staff();
break;
case 3:
s.delete_staff();
break;
case 4:
s.amend_staff();
break;
case 5:
s.find_staff();
break;
case 0: break;
}
} while (chioce != 0);
system("pause");
}
void trader() { //交易信息管理界面
int chioce;
deal s;
system("cls");
do {
system("cls");
cout "1.显示交易信息" endl;
cout "2.添加交易信息" endl;
cout "3.删除交易信息" endl;
cout "4.查询交易信息" endl;
cout "0.返回" endl;
cout "请输入你的选择:";
cin >> chioce;
while (chioce 0 || chioce>5) {
cout "请重新输入你的选择:";
cin >> chioce;
}
switch (chioce) {
case 1:
s.dis_deal();
break;
case 2:
s.get_deal();
break;
case 3:
s.delete_deal();
break;
case 4:
s.find_deal();
break;
}
} while (chioce != 0);
system("pause");
}
void rental() { //用户租赁房屋
cout "请选择你要租赁得房屋编号:";
char a[20];
cin >> a;
house s;
deal s1;
float b=s.amend_status(a);
s1.auto_deal(b);
cout "租赁成功!" endl;
system("pause");
}
void UI() {
system("cls");
int chioce;
int n = 1;
do {
cout "请输入用户名:";
char a[20]; cin >> a;
cout "请输入密码:";
char b[20]; cin >> b;
customer_information s;
while (!s.find(a, b)) {
cout "请重新输入用户名:"; cin >> a;
cout "请重新输入密码:"; cin >> b;
}
if (s.find(a, b)) {
n = 0;
cout "登录成功!" endl;
system("pause");
}
} while (n);
system("cls");
house s;
look_house sss;
customer_information ss;
do {
system("cls");
cout "1.显示房屋信息" endl;
cout "2.租赁房屋" endl;
cout "3.实地看房" endl;
cout "4.修改密码" endl;
cout "0.返回" endl;
cout "请输入你的选择:";
cin >> chioce;
switch (chioce) {
case 1:
s.dis_house();
break;
case 2:
s.dis_house();
rental();
break;
case 3:
s.dis_house();
sss.get_look();
break;
case 4:
ss.amend();
break;
}
} while (chioce);
}
bool login_management() {
bool m = false;
system("cls");
char code[20];
char temp[20];
ifstream fin("code.dat");
if (!fin) {
cout "打开文件code.dat失败!" endl;
abort();
}
int chioce = 1;
fin >> code;
fin.close();
cout "请输入密码:";
cin >> temp;
do {
if (strcmp(code, temp) == 0) { m = true; chioce = 0; }
else { cout "密码错误!请重新输入:"; cin >> temp; }
} while (chioce);
return m;
}
void look_look() {
look_house s;
int chioce = 1;
do {
system("cls");
cout "1.显示看房信息n";
cout "2.修改看房信息n";
cout "3.删除看房信息n";
cout "4.查询看房信息n";
cout "0.返回n";
cout "请输入你的选择:";
cin >> chioce;
while (chioce > 4 || chioce 0) {
cout "请重新输入你的选择:";
cin >> chioce;
}
switch (chioce) {
case 1:
s.dis_look();
break;
case 2:
s.amend_look();
break;
case 3:
s.delete_look();
break;
case 4:
s.find_look();
break;
}
} while (chioce);
}
void chioces(int chioce) {
system("cls");
deal s;
switch (chioce) {
case 1:
Customer_management();
break;
case 2:
housing_management();
break;
case 3:
staff_management();
break;
case 4:
trader();
break;
case 5:
code_file_delete();
break;
case 6:
cout "总佣金收入:" s.brokerage() endl;
system("pause");
break;
case 7:
look_look();
break;
case 0:
break;
}
}
void sign_in() { //注册函数
system("cls");
string name; //租房者姓名
char password[20]; //租房者密码
string sex; //租房者性别
char phone[20]; //租房者电话号码
string profession; //租房者职业
cout "请输入你的用户名:"; cin >> name;
cout "请设置你的密码:"; cin >> password;
cout "请输入你的性别:"; cin >> sex;
cout "请输入你的电话号码:"; cin >> phone;
cout "请输入你的职业:"; cin >> profession;
ofstream fout("tenant.txt", ios::app);
if (!fout) {
cout "打开文件tenant.txt失败!" endl;
abort();
}
kk = kk + 1;
fout kk " " name " " password " " sex " " phone " " profession "n";
fout.close();
cout "注册成功!" endl;
system("pause");
}
int main()
{
int flag = true;
int chioce;
code_file_Read();
while (flag)
{
system("cls");
cout endl;
cout endl;
cout endl;
cout setw(60) " 欢迎进入房屋租赁系统 " endl;
cout endl;
cout endl;
cout endl;
cout setw(60) " ══════════════════" endl;
cout setw(60) "║ ║" endl;
cout setw(60) "║ ║" endl;
cout setw(60) "║ 管理员登录(1): ║" endl;
cout setw(60) "║ ║" endl;
cout setw(60) "║ ║" endl;
cout setw(60) "║ 用户登录(2): ║" endl;
cout setw(60) "║ ║" endl;
cout setw(60) "║ ║" endl;
cout setw(60) "║ 注册(3) ║" endl;
cout setw(60) "║ ║" endl;
cout setw(60) "║ ║" endl;
cout setw(60) "║ 退出系统(4): ║" endl;
cout setw(60) "║ ║" endl;
cout