?? main.cpp.bak
字號:
// main.cpp : Defines the entry point for the console application.
//
/*
* File: main.cpp
* ---------------
* This program runs the management of the hotel.
*/
#include "base.h"
#include "hotel.h"
#include "login.h"
/* Constants */
#define debug false
#define MAXLOGIN 4
/* Package variables */
class Login login;
/* Function prototypes */
/*
* Function: Login
* Usage: int=Login();
* --------------------------
* This function provides an interface to
* checks the login info,
* and if login in successfully,it will
* return the user's level,or exit the
* application.
*/
int Login( void );
/*
* Function: Init
* Usage: Init();
* ----------------------------------
* This procedure initializes the hotel info,
* includes the accounts and rooms info.
*/
void Init( void );
/*
* Function: Menu
* Usage: Menu(level);
* -----------------------------------
* This function shows a Menu to allow user
* to enter the operation commands,the kind
* of functions provided to the user is
* depended on the level.
*/
void Menu( int );
/*
* Function: Work
* Usage: Work(command,level);
* --------------------------------
* This function execute the command given.
*/
void Work( char , int );
/*
* The Main Function..
*/
int main()
{
//system("mkdir data");
//exit(0);
cout<<"OK"<<endl;
return 0;
int level=Login();
Init();
string com="c";
cout<<"***************************"<<endl;
cout<<"* *"<<endl;
cout<<"* Welcome to AutumnHotel~ *"<<endl;
cout<<"* *"<<endl;
cout<<"***************************"<<endl;
while (1) {
Menu(level);
com=GetString();
Work(com[0],level);
}
return 0;
}
int Login( void )
{
string user;
string pass;
int level=0;
int i=0;
while (i < MAXLOGIN){
cout<<"=========Login========="<<endl;
cout<<"Please input UESR name :";
user=GetString();
cout<<"Please input PASSWORD :";
pass=GetString();
if (0 == (level=login.LoginSuccess(user,pass) ) ) i++;
else {cout<<"=========Success==========="<<endl;return level;}
}
if (i == MAXLOGIN) exit(0);
return level;
}
void Init( void )
{
ClearAccountManageInfo(&accountManage);
ClearRoomManageInfo(&roomManage);
InitAccount(ACCOUNTFILE,&accountManage);
if (debug) cout<<"account ok"<<endl;
InitRoom(ROOMFILE,&roomManage);
if (debug) cout<<"room OK~"<<endl;
SetAccountRoomList(&accountManage,&roomManage);
return ;
}
void Menu( int level )
{
cout<<endl;
cout<<"============Main Menu==========="<<endl;
if (level > 0){
cout<<"a -list all accounts"<<endl;
cout<<"g -list accounts in hotel"<<endl;
cout<<"r -list all rooms"<<endl;
cout<<"l -list ClEAN rooms"<<endl;
cout<<"n -list INUSE rooms"<<endl;
cout<<"d -list NEEDFIX rooms"<<endl;
cout<<"e -list NEEDCLEAR rooms"<<endl;
cout<<"m -list not enough money accounts"<<endl;
cout<<"y -list one room info"<<endl;
}
if (level > 1){
cout<<"z -list one account info"<<endl;
cout<<"h -check in"<<endl;
cout<<"u -check out"<<endl;
cout<<"f -add fee"<<endl;
cout<<"t -change room state"<<endl;
}
if (level > 2){
cout<<"c -clear"<<endl;
cout<<"j -add account"<<endl;
cout<<"k -add room"<<endl;
cout<<"p -delete account"<<endl;
cout<<"x -delete room"<<endl;
cout<<"i -input from file"<<endl;
cout<<"o -output to file"<<endl;
cout<<"v -add user"<<endl;
cout<<"w -delete user"<<endl;
}
cout<<"q -quit"<<endl;
cout<<"=============End==================="<<endl;
cout<<"Please input your choice :";
return;
}
void Work( char com , int level )
{
switch (level)
{
case 3:
switch (com)
{
case 'c':{
ClearAccountManageInfo(&accountManage);
ClearRoomManageInfo(&roomManage);
break;
}
case 'i':{
ClearAccountManageInfo(&accountManage);
ClearRoomManageInfo(&roomManage);
InitAccount(ACCOUNTFILE,&accountManage);
InitRoom(ROOMFILE,&roomManage);
break;
}
case 'j':{
AddAccount(&accountManage);
break;
}
case 'k':{
AddRoom(&roomManage);
break;
}
case 'p':{
DeleteAccount(&accountManage);
break;
}
case 'x':{
DeleteRoom(&roomManage);
break;
}
case 'o':{
OutAccount(ACCOUNTFILE,&accountManage);
OutRoom(ROOMFILE,&roomManage);
break;
}
case 'v':{
AddUser(&login);
break;
}
case 'w':{
DeleteUser(&login);
break;
}
default :break;
}
case 2:
switch (com)
{
case 'h':{
CheckIn(&accountManage,&roomManage);
break;
}
case 'u':{
CheckOut(&accountManage,&roomManage);
break;
}
case 'f':{
AddFee(&accountManage);
break;
}
case 't':{
ChangeRoomState(&roomManage);
break;
}
case 'z':{
PrintAccountInfo(&accountManage);
break;
}
default:break;
}
case 1:
switch (com)
{
case 'a':{
PrintAllAccount(&accountManage);
break;
}
case 'r':{
PrintAllRoom(&roomManage);
break;
}
case 'g':{
PrintGuestInHotel(&accountManage);
break;
}
case 'l':{
PrintStateRoom(&roomManage,CLEAN);
break;
}
case 'n':{
PrintStateRoom(&roomManage,INUSE);
break;
}
case 'd':{
PrintStateRoom(&roomManage,NEEDFIX);
break;
}
case 'e':{
PrintStateRoom(&roomManage,NEEDCLEAR);
break;
}
case 'm':{
PrintNotEnoughAccount(&accountManage);
break;
}
case 'y':{
PrintRoomInfo(&roomManage);
break;
}
case 'q':{
OutAccount(ACCOUNTFILE,&accountManage);
OutRoom(ROOMFILE,&roomManage);
cout<<"Bye~"<<endl;
exit(0);
break;
}
default:break;
}
default:break;
}
return ;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -