⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 room.cpp

📁 命令行模式下的简单宾馆管理系统..各种基本功能齐全..属于新人练习作品..hotel manager..
💻 CPP
字号:
/*
 * File: room.cpp
 * --------------
 * This file implements the room.h interface. 
 */




#include "room.h"

/* Implementation */

Room::Room()
{
	roomNum=0;
	chargingHours=24;
	roomPrice=200;
	dealPrice=0;
	roomType=SINGLE;
	roomState=CLEAN;
	customerName="autumn";
	customerID=0;
}
void Room::SetInfo()	//add
{
}
void Room::SetRoomNum( int num )
{
	roomNum=num;
}
void Room::SetRoomType( RoomType type )
{
	roomType=type;
}
void Room::SetBusinessNum( int num )
{
	businessNum=num;
}
void Room::SetRoomPrice( int price)
{
	roomPrice=price;
}
void Room::SetChargingHours( int hour)
{
	chargingHours=hour;
}
void Room::SetCustomerName( string name )
{
	customerName=name;
}
void Room::SetCustomerID( int id )
{
	customerID=id;
}
void Room::SetStartDate( int dy, int mh, int yr )
{
	startDate.SetDate(dy,mh,yr);
}
void Room::SetStartTime( int sd, int me, int hr )
{
	startTime.SetTime(sd,me,hr);
}
void Room::SetDealPrice( int price )
{
	dealPrice=price;
}
void Room::SetRoomState( RoomState state )
{
	roomState=state;
}
int Room::GetCurExpences()
{
	curTime=time(NULL);
	tm *pt=localtime(&curTime);
	int timeHour=0;
	int tempExp=0;
	timeHour+=pt->tm_hour - startTime.GetHour();
	timeHour+=(pt->tm_year - startDate.GetYear())*365*24;
	timeHour+=(pt->tm_mon + 1 - startDate.GetMonth())*12*24;
	timeHour+=(pt->tm_mday - startDate.GetDay())*24;
	tempExp+=int((timeHour-1) / chargingHours + 1) * dealPrice;
	return tempExp;
}
int Room::GetRoomNum()
{
	return roomNum;
}
int Room::GetCustomerID()
{
	return customerID;
}
/*
Date *Room::GetStartDate()
{
	return &startDate;
}
Time *Room::GetStartTime()
{
	return &startTime;
}
*/
RoomState Room::GetRoomState()
{
	return roomState;
}
string Room::GetRoomCustomerName()
{
	return customerName;
}
void Room::PrintInfoBrief()
{
	cout<<roomNum<<"  ";
	switch(roomType)
	{
		case SINGLE:cout<<"Single";break;
		case DOUBLE:cout<<"Double";break;
		case TRIPLE:cout<<"Triple";break;
		case SUITE:cout<<"Suite";break;
		default:break;
	}
	cout<<"  ";
	switch(roomState)
	{
		case CLEAN:cout<<"Clean"<<endl;break;
		case INUSE:cout<<"InUse"<<endl;break;
		case NEEDFIX:cout<<"NeedFix"<<endl;break;
		case NEEDCLEAR:cout<<"NeedClear"<<endl;break;
		default :break;
	}
}
void Room::WriteToFile( ofstream *fout )///
{
	*fout << "<ROOM>" << endl << roomNum << ' ' << roomType << ' ' << businessNum << ' '
	     << roomPrice << ' ' << chargingHours << endl << customerName << endl
		 << customerID << ' ' << dealPrice << ' ' << roomState << ' ' 
		 << startDate.GetYear() << ' ' << startDate.GetMonth() << ' ' 
		 << startDate.GetDay() << ' ' << startTime.GetHour() << ' '
		 << startTime.GetMinute() << ' ' << startTime.GetSecond() << endl;
	
}
void Room::ReadFromFile( ifstream *fin )///
{
	string temp_s;
	int tyr, tmh, tdy, thr, tsd, tme, rType, rState;
	*fin >> temp_s;
	*fin >> roomNum >> rType >> businessNum >> roomPrice >> chargingHours;
	(*fin).ignore(max_c,'\n');
	getline(*fin,customerName,'\n');
	*fin >> customerID >> dealPrice >> rState >> tyr >> tmh >> tdy >> thr >> tsd >> tme;
	startDate.SetDate(tdy, tmh, tyr);
	startTime.SetTime(tsd, tme, thr);
	roomType = RoomType(rType);
	roomState = RoomState(rState);
}
void Room::PrintInfo()
{
	cout<<"RoomNum:"<<roomNum<<endl;
	cout<<"RoomType:";
	switch(roomType)
	{
		case SINGLE:cout<<"Single"<<endl;break;
		case DOUBLE:cout<<"Double"<<endl;break;
		case TRIPLE:cout<<"Triple"<<endl;break;
		case SUITE:cout<<"Suite"<<endl;break;
		default:break;
	}
	cout<<"RoomPrice:"<<roomPrice<<endl;
	cout<<"RoomDealPrice:"<<dealPrice<<endl;
	cout<<"ChargingHours:"<<chargingHours<<endl;
	cout<<"RoomState:";
	switch(roomState)
	{
		case CLEAN:cout<<"Clean"<<endl;break;
		case INUSE:cout<<"InUse"<<endl;break;
		case NEEDFIX:cout<<"NeedFix"<<endl;break;
		case NEEDCLEAR:cout<<"NeedClear"<<endl;break;
		default :break;
	}
	cout<<"-EOF-"<<endl;
}
Room::~Room()
{
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -