资源描述
程序设计报告
( 2012 / 2013 学年 第 一 学期)
题 目: 房屋租售管理系统
专 业
学 生 姓 名
班 级 学 号
指 导 教 师
指 导 单 位
日 期 2012.11.02
评 分 细 则
评分项
优秀
良好
中等
差
遵守机房规章制度
上机时的表现
学习态度
程序准备情况
程序设计能力
团队合作精神
课题功能实现情况
算法设计合理性
用户界面设计
报告书写认真程度
内容详实程度
文字表达熟练程度
回答问题准确度
简 短 评 语
教师签名:
年 月 日
评分等级
备注
评分等级有五种:优秀、良好、中等、及格、不及格
房屋租售管理系统
一、 课题内容和要求
该系统要求建立某房屋租售中介管理系统,并实现输入口令进入系统、基础信息建立、客户统计、房源排序、销售业绩及佣金收入统计、相关文件存盘功能。
通过此课题,熟练掌握文件、数组、指针的各种操作,以及一些算法思想的应用。
二、需求分析
模块一:基础信息管理,该模块实现员工、楼盘及门店信息的查看与建立;
模块二:客户管理,该模块实现客户信息的建立、查看与各类客户数量统计;
模块三:房源查看,该模块实现房源信息按租金升序、售金升序、租金降序、售金降序显示;
模块四:统计分析,该模块实现某一指定时间段内销售情况及佣金收入统计;
模块五:保存文件,该模块实现各类相关文件的保存;
模块六:退出系统,该模块实现本系统的退出;
三、概要设计 开始
输入密码
密码正确
确
N
Y
进入系统
统计分析
保存文件
退出系统
房源查看
客户管理
基础信息管理
1 2 3 4 5 0
结束
1.基础信息管理:包括楼盘信息查询、员工信息查询、门店信息查询、楼盘信息建立、员工信息建立、门店信息建立、返回上级菜单几项功能;
2.客户管理:包括客户信息查询、客户信息建立、客户数量统计及返回上级菜单几项功能;
3.房源查看:包括按租金升序显示房源信息、按租金降序显示房源信息、按售金升序显示房源信息、按售金降序显示房源信息及返回上级菜单几项功能;
4.统计分析:包括销售情况及佣金收入统计及返回上级菜单几项功能;
5.保存文件:保存所有相关文件;
6.退出系统:退出房屋租售管理系统。
四、源程序代码
#include<iostream>
#include<iomanip>
#include<fstream>
#include<string>
#include<stdlib.h>
#include<set>
using namespace std;
class Date //定义日期类
{
protected:
int year; //年
int month; //月
int day; //日
public:
void Set(int,int,int); //设置日期
void Input(); //输入日期
bool operator<(Date ob)const; //重载<运算,实现日期比较
int GetYear(); //返回年
int GetMonth(); //返回月
int GetDay(); //返回日
};
//Date类函数的实现
void Date::Set(int y,int m,int d)
{
year=y;
month=m;
day=d;
}
void Date::Input()
{
cout<<"年: ";
cin>>year;
cout<<"月: ";
cin>>month;
cout<<"日: ";
cin>>day;
}
bool Date::operator<(Date ob)const
{
if(year<ob.year)
return true;
else
if(year==ob.year)
if(month<ob.month)
return true;
else
if(month==ob.month)
if(day<ob.day)
return true;
else
return false;
else
return false;
else
return false;
}
int Date::GetYear()
{
return year;
}
int Date::GetMonth()
{
return month;
}
int Date::GetDay()
{
return day;
}
class Floor //定义楼盘类
{
protected:
string Num; //楼盘编号
double Size; //楼盘面积
double Hire; //楼盘租金
double Buy; //楼盘售金
bool State; //楼盘状态(1-售,0-租)
Date Da; //租出/售出日期
public:
Floor(string nu,double si,double hi,double bu,bool st,int y,int m,int d); //构造函数
void Input(); //输入单个楼盘信息
bool operator<(Floor ob)const; //重载<运算,set容器要求元素之间满足该关系
string GetNum(); //返回楼盘编号
double GetSize(); //返回楼盘面积
double GetHire(); //返回楼盘租金
double GetBuy(); //返回楼盘售金
bool GetState(); //返回楼盘状态
Date GetDa(); //返回楼盘租出/售出日期
};
//Floor类函数的实现
Floor::Floor(string nu,double si,double hi,double bu,bool st,int y,int m,int d)
{
Num=nu;
Size=si;
Hire=hi;
Buy=bu;
State=st;
Da.Set(y,m,d);
}
void Floor::Input()
{
cout<<"楼盘编号: ";
cin>>Num;
cout<<endl;
cout<<"楼盘面积: ";
cin>>Size;
cout<<endl;
cout<<"楼盘租金: ";
cin>>Hire;
cout<<endl;
cout<<"楼盘售金: ";
cin>>Buy;
cout<<endl;
cout<<"楼盘状态(0-租;1-售): ";
cin>>State;
cout<<endl;
cout<<"租出/售出日期: \n";
Da.Input();
}
bool Floor::operator<(Floor ob)const
{
if(Num<ob.Num)
return true;
else
return false;
}
string Floor::GetNum()
{
return Num;
}
double Floor::GetSize()
{
return Size;
}
double Floor::GetHire()
{
return Hire;
}
double Floor::GetBuy()
{
return Buy;
}
bool Floor::GetState()
{
return State;
}
Date Floor::GetDa()
{
return Da;
}
class Staff //定义员工类
{
protected:
string Number; //员工编号
string Name; //员工姓名
char Sex; //员工性别
string Tel; //员工电话
double Commission; //员工工资
public:
Staff(string num,string na,char se,string te,double co); //构造函数
void Input(); //输入员工信息
bool operator<(Staff ob)const; //重载<运算,set容器要求元素之间满足该关系
string GetNumber(); //返回员工编号
string GetName(); //返回员工姓名
char GetSex(); //返回员工性别
string GetTel(); //返回员工电话
double GetCommission(); //返回员工工资
};
//Staff类函数的实现
Staff::Staff(string num,string na,char se,string te,double co)
{
Number=num;
Name=na;
Sex=se;
Tel=te;
Commission=co;
}
void Staff::Input()
{
cout<<"员工姓名: ";
cin>>Name;
cout<<"员工编号: ";
cin>>Number;
cout<<"员工性别(\"f\"或\"m\"): ";
cin>>Sex;
cout<<"员工电话: ";
cin>>Tel;
cout<<"员工工资: ";
cin>>Commission;
}
bool Staff::operator<(Staff ob)const
{
if(Number<ob.Number)
return true;
else
return false;
}
string Staff::GetNumber()
{
return Number;
}
string Staff::GetName()
{
return Name;
}
char Staff::GetSex()
{
return Sex;
}
string Staff::GetTel()
{
return Tel;
}
double Staff::GetCommission()
{
return Commission;
}
class Store //定义门店类
{
protected:
string StoNum; //门店编号
int StaffNum; //员工数量
int FloorNum; //负责楼盘数量
public:
Store(string sn,int st,int fl); //构造函数
void Input(); //输入门店信息
bool Store::operator<(Store ob)const; //重载<运算,set容器要求元素之间满足该关系
string GetStoNum(); //返回门店编号
int GetStaffNum(); //返回员工数量
int GetFloorNum(); //返回负责楼盘数量
};
//Store类函数的实现
Store::Store(string sn,int st,int fl)
{
StoNum=sn;
StaffNum=st;
FloorNum=fl;
}
void Store::Input()
{
cout<<"门店编号: ";
cin>>StoNum;
cout<<endl;
cout<<"员工数量: ";
cin>>StaffNum;
cout<<endl;
cout<<"负责楼盘数量: ";
cin>>FloorNum;
cout<<endl;
}
bool Store::operator<(Store ob)const
{
if(StoNum<ob.StoNum)
return true;
else
return false;
}
string Store::GetStoNum()
{
return StoNum;
}
int Store::GetStaffNum()
{
return StaffNum;
}
int Store::GetFloorNum()
{
return FloorNum;
}
class Client //定义客户类
{
protected:
string name; //客户姓名
string number; //客户编号
char sex; //客户性别
string tel; //客户电话
int type; //客户类别
public:
Client(string na,string nu,char se,string te,int ty); //构造函数
void Input(); //输入客户信息
bool Client::operator<(Client ob)const; //重载<运算,set容器要求元素之间满足该关系
string GetName(); //返回客户姓名
string GetNumber(); //返回客户编号
char GetSex(); //返回客户性别
string GetTel(); //返回客户电话
int GetType(); //返回客户类型
};
//Client类函数实现
Client::Client(string na,string nu,char se,string te,int ty)
{
name=na;
number=nu;
sex=se;
tel=te;
type=ty;
}
void Client::Input()
{
cout<<"客户姓名: ";
cin>>name;
cout<<"客户编号: ";
cin>>number;
cout<<"客户性别(\"f\"或\"m\"): ";
cin>>sex;
cout<<"客户电话: ";
cin>>tel;
cout<<"客户类型(1-求租客户;2-求售客户;3-出租客户;4-出售客户): ";
cin>>type;
}
bool Client::operator<(Client ob)const
{
if(number<ob.number)
return true;
else
return false;
}
string Client::GetName()
{
return name;
}
string Client::GetNumber()
{
return number;
}
char Client::GetSex()
{
return sex;
}
string Client::GetTel()
{
return tel;
}
int Client::GetType()
{
return type;
}
class Admin
{
protected:
set<Floor> fl; //Floor类数据集
set<Staff> sta; //Staff类数据集
set<Store> sto; //Store类数据集
set<Client> cl; //Client类数据集
public:
Admin(); //构造函数
void ReadFloor(); //读取楼盘文件
void ReadStaff(); //读取员工文件
void ReadStore(); //读取门店文件
void ReadClient(); //读取客户文件
void ShowFloorInfo(); //显示所有楼盘信息
void ShowStaffInfo(); //显示所有员工信息
void AddFloor(); //添加楼盘信息
void AddStaff(); //添加员工信息
void ShowStoreInfo(); //显示所有门店信息
void AddStore(); //添加门店信息
void ShowClientInfo(); //显示所有客户信息
void AddClient(); //添加客户信息
void HireRise(); //按租金升序显示所有楼盘信息
void HireFall(); //按租金降序显示所有楼盘信息
void BuyRise(); //按售金升序显示所有楼盘信息
void BuyFall(); //按售金降序显示所有楼盘信息
void SellSta(); //某段时间内销售及佣金收入统计
void ClientSta(); //客户信息统计
void SaveFloor(); //楼盘信息存档
void SaveStaff(); //员工信息存档
void SaveStore(); //门店信息存档
void SaveClient(); //客户信息存档
};
Admin::Admin() //定义对象的同时读取文件
{
ReadFloor();
ReadStaff();
ReadStore();
ReadClient();
}
void Admin::ReadFloor()
{
ifstream in("C:\\FloorInfo.txt");
if(!in)
{
cout<<"Cannot open the file:\"FloorInfo.txt\"\n";
return ;
}
string Num;
double Size;
double Hire;
double Buy;
bool State;
int y;
int m;
int d;
set<Floor>::iterator p=fl.begin();
in>>Num>>Size>>Hire>>Buy>>State>>y>>m>>d;
while(!in.eof())
{
Floor ob(Num,Size,Hire,Buy,State,y,m,d);
fl.insert(ob);
in>>Num>>Size>>Hire>>Buy>>State>>y>>m>>d;
}
in.close();
return;
}
void Admin::ReadStaff()
{
ifstream in("C:\\StaffInfo.txt");
if(!in)
{
cout<<"Cannot open the file:\"StaffInfo.txt\"\n";
return ;
}
string Number;
string Name;
char Sex;
string Tel;
double Commission;
set<Staff>::iterator p=sta.begin();
in>>Number>>Name>>Sex>>Tel>>Commission;
while(!in.eof())
{
Staff ob(Number,Name,Sex,Tel,Commission);
sta.insert(ob);
in>>Number>>Name>>Sex>>Tel>>Commission;
}
in.close();
return;
}
void Admin::ReadStore()
{
ifstream in("C:\\StoreInfo.txt");
if(!in)
{
cout<<"Cannot open the file:\"StoreInfo.txt\"\n";
return ;
}
string StoNum;
int StaffNum;
int FloorNum;
set<Store>::iterator p=sto.begin();
in>>StoNum>>StaffNum>>FloorNum;
while(!in.eof())
{
Store ob(StoNum,StaffNum,FloorNum);
sto.insert(ob);
in>>StoNum>>StaffNum>>FloorNum;
}
in.close();
return;
}
void Admin::ReadClient()
{
ifstream in("C:\\ClientInfo.txt");
if(!in)
{
cout<<"Cannot open the file:\"ClientInfo.txt\"\n";
return ;
}
string name;
string number;
char sex;
string tel;
int type;
set<Client>::iterator p=cl.begin();
in>>number>>name>>sex>>tel>>type;
while(!in.eof())
{
Client ob(name,number,sex,tel,type);
cl.insert(ob);
in>>number>>name>>sex>>tel>>type;
}
in.close();
return;
}
void Admin::ShowFloorInfo()
{
system("cls");
cout<<"楼盘编号 楼盘面积 楼盘租金 楼盘售金 楼盘状态 租出/售出日期\n";
set<Floor>::iterator p=fl.begin();
while(p!=fl.end())
{
cout<<" "<<p->GetNum()<<"\t "<<p->GetSize()<<"\t "<<p->GetHire()<<"\t "<<p->GetBuy()<<"\t ";
if(p->GetState())
cout<<"售\t ";
else
cout<<"租\t ";
Date bi=p->GetDa();
cout<<bi.GetYear()<<"-"<<bi.GetMonth()<<"-"<<bi.GetDay()<<endl;
p++;
}
}
void Admin::ShowStaffInfo()
{
system("cls");
cout<<"员工编号\t员工姓名\t员工性别\t员工电话\t员工工资\n";
set<Staff>::iterator p=sta.begin();
while(p!=sta.end())
{
cout<<" "<<p->GetNumber()<<"\t\t"<<p->GetName()<<"\t\t ";
if(p->GetSex()=='f')
cout<<"男\t\t";
else
cout<<"女\t\t";
cout<<p->GetTel()<<"\t "<<p->GetCommission()<<"\n";
p++;
}
}
void Admin::ShowStoreInfo()
{
system("cls");
cout<<"门店编号 员工数量 负责楼盘数量\n";
set<Store>::iterator p=sto.begin();
while(p!=sto.end())
{
cout<<" "<<p->GetStoNum()<<"\t "<<p->GetStaffNum()<<"\t "<<p->GetFloorNum()<<endl;
p++;
}
}
void Admin::ShowClientInfo()
{
system("cls");
cout<<"客户编号 客户姓名 客户性别 客户电话 客户类别\n";
set<Client>::iterator p=cl.begin();
while(p!=cl.end())
{
cout<<" "<<p->GetNumber()<<"\t "<<p->GetName()<<"\t";
if(p->GetSex()=='f')
cout<<"男 ";
else
cout<<"女 ";
cout<<p->GetTel()<<"\t";
if(p->GetType()==1)
cout<<"求租客户\n";
else if(p->GetType()==2)
cout<<"求售客户\n";
else if(p->GetType()==3)
cout<<"出租客户\n";
else
cout<<"出售客户\n";
p++;
}
}
void Admin::AddFloor()
{
char ch='n';
do
{
Floor ob("1",1,1,1,1,1,1,1);
ob.Input();
fl.insert(ob);
cout<<"继续输入?(y/n)"<<endl;
cin>>ch;
}while(ch=='y');
}
void Admin::AddStaff()
{
char ch='n';
do
{
Staff ob("1","1",'1',"1",1);
ob.Input();
sta.insert(ob);
cout<<"继续输入?(y/n)"<<endl;
cin>>ch;
}while(ch=='y');
}
void Admin::AddStore()
{
char ch='n';
do
{
Store ob("1",1,1);
ob.Input();
sto.insert(ob);
cout<<"继续输入?(y/n)"<<endl;
cin>>ch;
}while(ch=='y');
}
void Admin::AddClient()
{
char ch='n';
do
{
Client ob("1","1",'1',"1",1);
ob.Input();
cl.insert(ob);
cout<<"继续输入?(y/n)"<<endl;
cin>>ch;
}while(ch == 'y');
}
void Admin::HireRise()
{
int count=0;
int i;
double r=0;
system("cls");
cout<<"楼盘编号 楼盘面积 楼盘租金 楼盘售金 楼盘状态 租出/售出日期\n";
set<Floor>::iterator p=fl.begin();
while(p!=fl.end()) //count用于楼盘计数
{
count=count+1;
p++;
}
for(i=0;i<count;i++)
{
double min=100000000;
p=fl.begin();
while(p!=fl.end())
{
if(p->GetHire()<min&&r<p->GetHire()) //提取大于上一轮min值的最小租金
min=p->GetHire();
p++;
}
r=min; //r用于记录min值
p=fl.begin();
while(p!=fl.end())
{
if(min==p->GetHire()) //输出本轮最小租金的楼盘信息
{
cout<<" "<<p->GetNum()<<"\t "<<p->GetSize()<<"\t "<<p->GetHire()<<"\t "<<p->GetBuy()<<"\t ";
if(p->GetState())
cout<<"售\t ";
else
cout<<"租\t ";
Date bi=p->GetDa();
cout<<bi.GetYear()<<"-"<<bi.GetMonth()<<"-"<<bi.GetDay()<<endl;
}
p++;
}
}
}
void Admin::HireFall()
{
int count=0;
int i;
system("cls");
cout<<"楼盘编号 楼盘面积 楼盘租金 楼盘售金 楼盘状态 租出/售出日期\n";
set<Floor>::iterator p=fl.begin();
while(p!=fl.end())
{
count=count+1;
p++;
}
double r=100000000;
for(i=0;i<count;i++)
{
double max=0;
p=fl.begin();
while(p!=fl.end())
{
if(max<p->GetHire()&&r>p->GetHire())
max=p->GetHire();
p++;
}
r=max;
p=fl.begin();
while(p!=fl.end())
{
if(max==p->GetHire())
{
cout<<" "<<p->GetNum()<<"\t "<<p->GetSize()<<"\t "<<p->GetHire()<<"\t "<<p->GetBuy()<<"\t ";
if(p->GetState())
cout<<"售\t ";
else
cout<<"租\t ";
Date bi=p->GetDa();
cout<<bi.GetYear()<<"-"<<bi.GetMonth()<<"-"<<bi.GetDay()<<endl;
}
p++;
}
}
}
void Admin::BuyRise()
{
int count=0;
展开阅读全文