C++编程 根据不同的角色,登录相应的UI界面

目录

效果展示 

源码分享

1.main.cpp【程序主入口】

2.CTools.h .cpp【工具类】

3.CtrBase.h .cpp【控件基类】

4.CLabel.h .cpp【标签类】

5.CEdit.h .cpp【编辑框类】

6.CButton.h .cpp【按钮类】

7.CWinBase.h .cpp【窗口基类】

8.CLogin.h .cpp【登录窗口】

9.CStaff.h .cpp【用户类】

10.CData.h .cpp【公共数据类】

11.CIndexWin.h .cpp【管理员窗口】

12.CManagerWin.h .cpp【经理窗口】

13.CWaiterWin.h .cpp【服务员窗口】


效果展示 

根据不同角色可以登录相应的角色界面:

主要学习:登录验证函数 公共数据类 编辑框内容清空 编辑框内容回删

源码分享

1.main.cpp【程序主入口】

#include<iostream>
using namespace std;
#include"CTools.h"
#include "CLabel.h"
#include"CEdit.h"
#include"CButton.h"
#include"CtrBase.h"
#include"CLogin.h"      //主界面
#include"CIndexWin.h"   //管理员界面
#include"CManagerWin.h" //经理界面
#include"CWaiterWin.h"  //服务员界面
#include<stdlib.h>
#include<windows.h>

int main()
{
	CLoginWin *login = new CLoginWin(12,5,30,20);
    CIndexWin *index = new CIndexWin(3,3,25,23);
	CManagerWin *manager = new CManagerWin(3,3,25,23);
	CWaiterWin *waiter = new CWaiterWin(3,3,25,30);	

	CWinBase *winArr[10] = {0};

	winArr[0] = login;   //点菜
	winArr[1] = index;   //管理员
	winArr[2] = manager; //经理
	winArr[3] = waiter;  //服务员

	int winIndex = 0;    //默认显示主界面 初始化为0
	
	while(1)
	{
		Sleep(1000);
		system("cls");
		winArr[winIndex]->showWindow();
		winIndex = winArr[winIndex]->WinRun();
	}
	return 0;
}

2.CTools.h .cpp【工具类】

#ifndef CTOOLS_H
#define CTOOLS_H
#define KEY_UP 72
#define KEY_DOWN 80
#define KEY_LEFT 75
#define KEY_RIGHT 77
#define KEY_ESC 27
#define KEY_ENTER 13
#define KEY_BACKSPACE 8

class CTools  //CTools::gotoxy();  静态成员函数调用的方法
{
public:
static void paintWindow(int startX,int startY,int width,int height);//打印窗口
static void gotoxy(int x,int y);//光标定位

/*
函数功能:字符串输入控制
函数参数:
int maxLen    允许输入最大长度
int inputType 允许输入的字符类型  0:数字 1:字母 2:字母+数字
int ips       数据显示格式        0:密文 1:明文
char str[]    存储输入字符
函数返回值:无
char str[]    char str[20]    char*str
*/
static void glb_string(int maxLen,int inputType,int ips,char str[]); 

/*
函数名:  int getkey()
函数功能:获取用户输入的任意键盘值
函数参数:无
函数返回:ascii  
*/
static int getkey();
};

#endif
#include "CTools.h"
#include <windows.h>//gotoxy
#include<stdio.h>
#include<conio.h>

void CTools::gotoxy(int x,int y)
{
	HANDLE hOut;
	COORD pos= {x,y};
	// 光标的起始位(第1列,第3行) 0是第1列 2是第3行
	hOut = GetStdHandle(STD_OUTPUT_HANDLE);
	SetConsoleCursorPosition(hOut, pos);
	//printf("定位光标位置搜索(%d,%d)\n",pos.X,pos.Y);
}

void CTools::paintWindow(int startX,int startY,int width,int height)    
{	
	int i=0;
	//打印顶部   
	//光标定位 找规律 ┗  ┛ ┏ ┓ ┃ ━
	//顶部 y不变 x 在变 (x-x+w)
	gotoxy(startX,startY);
	printf("┏");
	for(i=0;i<width-2;i++)  //控制循环次数width-2次
	{		
		printf("━ ");
	}
	printf("┓");

	//左边 x不变 y在变 (y到y+height)
	for(i=1;i<=height-1;i++)
	{
		gotoxy(startX,startY+i);
		printf("┃");
	}

	//右边 x不变 =startx+width-1  y在变 y 到 y+height
	for(i=1;i<=height-1;i++)
	{
		gotoxy(startX+width*2-3,startY+i);
		printf("┃");
	}

	//底部 x在变化    y不变 (x到x+width) ━ 
	gotoxy(startX,startY+height-1);
	printf("┗");
	for(i=0;i<width-2;i++)
	{
		printf("━ ");	
	}
	printf("┛");

	gotoxy(startX,startX+height);
}

void CTools::glb_string(int maxLen,int inputType,int ips,char str[])
{
	   char ch=0;
	   int i=0;
	   while(1)
	   {
		   ch=getch();
		   if(ch=='\r'&&i>0)//换行结束输入
		   {		   
			   break;		   
		   }
		   switch(inputType)
		   {
		   case 0:
			   if(ch>='0'&&ch<='9'&&i<maxLen)
			   {
				   if(ips==0)
				   {
					   putch('*');				   
				   }
				   else{		   
					   putch(ch);
				   }
				   str[i++]=ch;			   
			   }
			   break;
		   case 1:
			   if(i<maxLen&&(ch>='a'&&ch<='z')||(ch>='A'&&ch<='Z'))
			   {
				   if(ips==0)
				   {
					   putch('*');				   
				   }
				   else{				   
					   putch(ch);
				   }
				   str[i++]=ch;		   
			   }
			   break;
		   case 2:
			   if(i<maxLen&&(ch>='a'&&ch<='z')||(ch>='A'&&ch<='Z')||(ch>='0'&&ch<='9'))
			   {
				   if(ips==0)
				   {
					   putch('*');	   
				   }
				   else{	   
					   putch(ch);
				   }
				   str[i++]=ch; 
			   }
			   break;
		   default:
			   break; 
		   }
	   }	   	   
}

/*
函数名:  int getkey()
函数功能:获取用户输入的任意键盘值
函数参数:无
函数返回:ascii  
*/
int CTools::getkey()
{
	char key=0;
	key=getch();
	if(key==-32)//方向按键 第一个值都是32
	{
		key=getch();
		switch(key){
		case 72:
			return KEY_UP;
		case 80:
			return KEY_DOWN;
		case 75:
			return KEY_LEFT;
		case 77:
			return KEY_RIGHT;	
		}		
	}
	else if(key==13)
	{
		return KEY_ENTER;
	}
	else if(key==27)
	{
		return KEY_ESC;
	}
	else if(key==8)
	{
		return KEY_BACKSPACE;
	}
	return key;
}

3.CtrBase.h .cpp【控件基类】

#ifndef CTRBASE_H
#define CTRBASE_H
#define LABEL 1
#define EDIT 2
#define BUTTON 3

class CtrBase
{
public:
	CtrBase();
	~CtrBase();
	CtrBase(int x,int y,int w,int h,char *pcontent,int type);
	virtual void show()=0;   //显示控件函数  纯虚函数
	int getX();
	int getY();
	int getW();
	int getH();
	char *getContent();
	int getType();
	virtual void backSpace();       //编辑框回删
	virtual void keyListen(char ch);//控件监听 虚函数
protected:  //派生类可以访问 父类protected修饰的属性
	int startX;
	int startY;
	int width;
	int height;
	char content[20];  //内容
	int ctrlType;      //控件类型
};

#endif
#include"CtrBase.h"
#include"CTools.h"
#include<iostream>
using namespace std;

CtrBase::CtrBase()
{
   	this->startX = 0;
	this->startY = 0;
	this->width = 0;
	this->height = 0;
	memset(content,'\0',sizeof(content));
	this->ctrlType = 0;
}

CtrBase::~CtrBase()
{
}

CtrBase::CtrBase(int x,int y,int w,int h,char *pcontent,int type)
{
	this->startX = x;
	this->startY = y;
	this->width = w;
	this->height = h;
	//内存的初始化
	memset(content,'\0',sizeof(content));
	strcpy(this->content,pcontent);
	this->ctrlType = type;
}

/*  纯虚函数
void CtrBase::show() //基类 可以不写 纯虚
{
  CTools::gotoxy(this->startX,this->startY);
  cout<<this->content<<endl;
}
*/

//为类对象访问提供公共接口
//类外访问
int CtrBase::getX()
{
	return this->startX;
}
int CtrBase::getY()
{
    return this->startY;
}
int CtrBase::getW()
{
    return this->width;
}
int CtrBase::getH()
{
    return this->height;
}
char* CtrBase::getContent()
{
	return this->content;
}
int CtrBase::getType()
{
	return this->ctrlType;
}

//由子类自己来实现各自的实现方法
void CtrBase::keyListen(char ch)//虚函数 里面没有任何内容
{
}

void CtrBase::backSpace()
{	
}

4.CLabel.h .cpp【标签类】

#ifndef CLABEL_H
#define CLABEL_H
#include"CtrBase.h"

class CLabel:public CtrBase  
{
public:
	void show();  //重写
	//构造函数
	CLabel();
	//析构函数
	~CLabel();
	CLabel(int x,int y,int w,int h,char pcontent[20],int type);
private:  
};

#endif
#include"CLabel.h"
#include<iostream>
using namespace std;
#include"CTools.h"

CLabel::CLabel()
{
}

CLabel::CLabel(int x,int y,int w,int h,char pcontent[20],int type)
:CtrBase(x,y,w,h,pcontent,type)
{
}

void CLabel::show()  
{
	CTools::gotoxy(this->startX,this->startY);
	cout<<this->content<<endl;
//	CtrBase::show();//纯虚函数
}

CLabel::~CLabel()
{
}

5.CEdit.h .cpp【编辑框类】

#ifndef CEDIT_H
#define CEDIT_H
#include"CtrBase.h"

class CEdit:public CtrBase 
{
public :
	CEdit();  
	CEdit(int x,int y,int w ,int h,char *pcontent,int maxLen,int inputType,int ips,int type);
	void show();
	void keyListen(char ch);
	void backSpace();//删除编辑框内容
	~CEdit(); 
private:
	int inputType;  //输入的类型
	int maxLen;     //最大长度
	int ips;        //明文密文
};

#endif
#include"CEdit.h"
#include"CTools.h"
#include<iostream>
using namespace std;
#include<conio.h>

CEdit::CEdit():CtrBase()  
{
	this->maxLen = 0;
	this->inputType = 0;
	this->ips = 0;
}

CEdit::CEdit(int x,int y,int w,int h,char *pcontent,
			int maxLen,int inputType,int ips,int type )
			:CtrBase(x,y,w,h,pcontent,type) 
			//顺序与基类相同 变量名与派生类一致
{
	this->maxLen = maxLen;
	this->inputType = inputType;
	this->ips = ips;
}

CEdit::~CEdit()
{
}

void CEdit::show()
{
	CTools::paintWindow(this->startX,this->startY,
				this->width,this->height);
	CTools::gotoxy(this->startX+2+strlen(this->content),this->startY+1);
	memset(this->content,'\0',sizeof(this->content));//内存初始化 清除编辑框内容
    cout<<this->content;
}

//多态 虚函数
//监听控件函数的具体实现
void CEdit::keyListen(char ch)
{
    int i=strlen(this->content);//从字符串原来的长度开始存储
	switch(this->inputType)
	{
	case 0: //数字
		if(ch>='0'&&ch<='9'&&i<this->maxLen)
		{
			if(this->ips==0)
			{
				putch('*');	
			}
			else{
			      putch(ch);
			}
			this->content[i++]=ch;			
		}
		break;
	case 1:  //字母
		if(i<this->maxLen&&((ch>='a'&&ch<='z')||(ch>='A'&&ch<='Z')))
		{
			if(this->ips==0)
			{
				putch('*');				
			}
			else{				
				putch(ch);
			}
			this->content[i++]=ch;			
		}
		break;
	case 2:  //数字+字母
		if(i<this->maxLen&&((ch>='a'&&ch<='z')||(ch>='A'&&ch<='Z')||(ch>='0'&&ch<='9')))
		{
			if(this->ips==0)
			{
				putch('*');				
			}
			else{				
				putch(ch);
			}
			this->content[i++]=ch;		
		}
		break;
	default:
		break;		
	}
}

void CEdit::backSpace()
{
	int i = strlen(this->content);//从字符串原来的长度开始存储
	if(i>0)
	{
		//输入框回删(表面回删)
		printf("\b \b");
		//数组内容回删(实际回删)
		this->content[--i] = '\0';
	}
	return;
}

6.CButton.h .cpp【按钮类】

#ifndef CBUTTON_H
#define CBUTTON_H
#include"CtrBase.h"

class CButton:public CtrBase    
{
public:
    //构造函数
	CButton();
    //带参数的构造
	CButton(int x,int y,int w,int h,char pcontent[],int type);
	//析构函数
	~CButton();
	void show();
private:   
};
#endif
#include"CButton.h"
#include<iostream>
using namespace std;
#include"CTools.h"

CButton::CButton()
{
}

CButton::CButton(int x,int y,int w,int h,char pcontent[],int type)
:CtrBase(x,y,w,h,pcontent,type)
{
}

CButton::~CButton()
{
}

void CButton::show()
{
	CTools::paintWindow(startX,startY,width,height);
	CTools::gotoxy(startX+(width*2-strlen(content))/2-1,startY+1);
	cout<<content<<endl; 
}

7.CWinBase.h .cpp【窗口基类】

#ifndef CWINBASE_H
#define CWINBASE_H
#include"CtrBase.h"

class CWinBase
{
public:
	CWinBase();
    CWinBase(int x,int y,int w,int h);
	virtual  ~CWinBase();
	void addControl(CtrBase *ctrl);
	void showWindow();
	int WinRun();
	virtual int doAction()=0;//抽象类 每一个子类方法各不相同
protected:
	int startX;
	int startY;
	int width;
	int height;
	int ctrlCount;
	CtrBase *ctrlArr[10];
	int focusIndex;       //按下回车键按钮的下标
};

#endif
#include"CWinBase.h"
#include"CTools.h"
#include<iostream>
using namespace std;

CWinBase::CWinBase()
{
	this->startX = 0;
	this->startY = 0;
	this->width = 0;
	this->height = 0;
	this->ctrlCount = 0;
}

CWinBase::CWinBase(int x,int y,int w,int h)
{
	this->startX = x;
	this->startY = y;
	this->width = w;
	this->height = h;
	this->ctrlCount = 0;
}

CWinBase::~CWinBase()
{
	for(int i=0;i<this->ctrlCount;i++)
	{
		delete this->ctrlArr[i];
	}  
}

//添加控件
void CWinBase::addControl(CtrBase *ctrl) //统一基类指针进行接收
{
	//派生类指针赋值给基类指针 范围缩小了
	this->ctrlArr[this->ctrlCount++] = ctrl;
}

//显示整个窗口及控件
void CWinBase::showWindow()
{
	//显示大框  显示每个控件
	CTools::paintWindow(this->startX,this->startY,this->width,this->height);
	for(int i=0;i<this->ctrlCount;i++)
	{
		this->ctrlArr[i]->show();  //执行基类的show函数	
	}
}

//窗口运行函数
int CWinBase::WinRun()
{
	int i=0,key=0;
	for(i=0;i<this->ctrlCount;i++)
	{
		if(this->ctrlArr[i]->getType()==EDIT||this->ctrlArr[i]->getType()==BUTTON)
		{
			CTools::gotoxy(this->ctrlArr[i]->getX()+2,this->ctrlArr[i]->getY()+1);
			break;
		}
	}
	while(1)
	{
		key=CTools::getkey();
		switch(key){
		case KEY_DOWN://向下按键  查找下一个编辑框 按钮
			i++;//按键数组下标越界
			if(i==this->ctrlCount)
			{
				i=0;//为了避免下标越界 从头开始对控件结构体数组找编辑框 按钮	
			}
			for(;i<this->ctrlCount;i++)
			{
				if(this->ctrlArr[i]->getType()==EDIT)
				{
					CTools::gotoxy(this->ctrlArr[i]->getX()+2+strlen(this->ctrlArr[i]->getContent())
				,this->ctrlArr[i]->getY()+1);
					break;	
				}
				else if(this->ctrlArr[i]->getType()==BUTTON)
				{
					CTools::gotoxy(this->ctrlArr[i]->getX()+(this->ctrlArr[i]->getW()-strlen(this->ctrlArr[i]->getContent())/2)
				,this->ctrlArr[i]->getY()+1);
					break;
				}
			}
			break;
		case KEY_UP:
			i--;
			if(i==-1)  //从后往前找 数组起始0 i--为-1 数组下标由大到小 (控件数组下标0位置)
			{
				i=this->ctrlCount-1;  //控件个数(控件结构体数组下标最大)-1 (控件数组下标ctrlCount位置)
		
			}
			for(;i>0;i--)
			{
				if(this->ctrlArr[i]->getType()==EDIT)
				{
					CTools::gotoxy(this->ctrlArr[i]->getX()+2+strlen(this->ctrlArr[i]->getContent())
				,this->ctrlArr[i]->getY()+1);
					break;
				}
				else if(this->ctrlArr[i]->getType()==BUTTON)
				{
					CTools::gotoxy(this->ctrlArr[i]->getX()+(this->ctrlArr[i]->getW()-strlen(this->ctrlArr[i]->getContent())/2)
				,this->ctrlArr[i]->getY()+1);
					break;
				}
				if(i==0)  //第一个 若第一个不是编辑框 按钮
				{
					i=this->ctrlCount;  //就从最后一个往前查找 for循环中有i--,不用再-1
				}
			}
			break;
		case KEY_ENTER:
			if(this->ctrlArr[i]->getType()==BUTTON)
			{
				this->focusIndex=i;
				return doAction();//返回切换到的界面的下标
				//获取winRun中输入的编辑框的值
			}
			break;
		default:   //其他字符(不是按键)并且当前控件是编辑框
			if(this->ctrlArr[i]->getType()==EDIT)
			{
				if(key==KEY_BACKSPACE)//执行回删
				{
					this->ctrlArr[i]->backSpace();			
				}
				else{
					this->ctrlArr[i]->keyListen(key);
				}
			}
			break;
		}
	}
}

/*
void CWinBase::doAction()//纯虚函数
{
//每个窗口都不一样 不需要写  
}
*/

8.CLogin.h .cpp【登录窗口】

#ifndef CLOGIN_H
#define CLOGIN_H
#include "CLabel.h"
#include"CEdit.h"
#include"CButton.h"
#include"CWinBase.h"

class CLoginWin:public CWinBase
{
public :
	CLoginWin();
	CLoginWin(int x,int y,int w,int h);
	~CLoginWin();
     int doAction();
	 int Jude();  //登录验证函数
private:
    CLabel *title,*labName,*labPwd;
	CButton *btnlogin ,*btnexit;
	CEdit *editName,*editPwd;
};

#endif
#include"CLogin.h"
#include"CTools.h"
#include"CData.h"//引入公共的数据文件
#include"CStaff.h"
#include<cstring>
#include<windows.h>//pause任意键继续
#include<iostream>
using namespace std;

CLoginWin::CLoginWin():CWinBase()
{
}

CLoginWin::CLoginWin(int x,int y,int w,int h)
:CWinBase(x,y,w,h)
{
	this->title = new CLabel(36,8,20,2,"点菜系统",LABEL);   //0
	this->labName = new CLabel(26,11,10,2,"用户名:",LABEL);//1
	this->labPwd = new CLabel(26,15,10,2,"密码:",LABEL);   //2
//int x,int y,int w,int h,char *pcontent,
//int maxLen,int inputType,int ips
	this->editName = new CEdit(34,10,10,3,"",8,2,1,EDIT);   //3
	this->editPwd = new CEdit(34,14,10,3,"",6,2,0,EDIT);    //4
	this->btnlogin = new CButton(25,18,6,3,"登录",BUTTON);  //5
	this->btnexit = new CButton(45,18,6,3,"退出",BUTTON);   //6

	this->addControl(this->title);
	this->addControl(this->labName);
	this->addControl(this->labPwd);
	this->addControl(this->editName);
	this->addControl(this->editPwd);
	this->addControl(this->btnlogin);
	this->addControl(this->btnexit);
}

CLoginWin::~CLoginWin()
{
}

//派生类实现基类的纯虚函数--重写
int CLoginWin::doAction()
{
	int role = -1;
	switch(this->focusIndex)
	{
	case 5:
        role = this->Jude();
		switch(role)
		{
		case ADMIN:
			CTools::gotoxy(33,21);
			cout<<"欢迎你,"<<this->editName->getContent()<<"管理员"<<endl;
			system("pause");
			return 1;
		case MANAGER:
			CTools::gotoxy(33,21);
			cout<<"欢迎你,"<<this->editName->getContent()<<"经理"<<endl;
			system("pause");			
			return 2;
		case WAITER:
			CTools::gotoxy(33,21);
			cout<<"欢迎你,"<<this->editName->getContent()<<"服务员"<<endl;
			system("pause");		
			return 3;	
		default:
			system("pause");
			return 0;	
		}
	}
}

int CLoginWin::Jude()
{
	for(int i=0;i<CData::staffCount;i++)
	{
		if(strcmp(this->editName->getContent(),CData::staffArr[i]->getName())==0)
		{
			if(strcmp(this->editPwd->getContent(),CData::staffArr[i]->getPwd())==0)
			{
				return CData::staffArr[i]->getRole();		
			}
			else
			{
				CTools::gotoxy(33,21);
				cout<<"密码错误"<<endl;
				break;	
			}
		}	
	}
	if(i == CData::staffCount)
	{
		CTools::gotoxy(33,21);
		cout<<"用户名不存在"<<endl;
	}
	return 0;
}

9.CStaff.h .cpp【用户类】

#ifndef CSTAFF_H
#define CSTAFF_H
#define ADMIN 1
#define MANAGER 2
#define WAITER 3

class Staff
{
public:
	Staff();
	Staff(int id,char *name,char *pwd,int prole);
	~Staff();
	char* getName();//对类外提供公共接口
	char* getPwd();
	int getRole();
private:
    int ID;
	char name[20];
	char pwd[20];
	int role;
};

#endif
#include"CStaff.h"
#include<cstring>
#include<iostream>
using namespace std;

Staff::Staff()
{
}

Staff::Staff(int id,char *name,char *pwd,int prole)
{
	this->ID = id;
	strcpy(this->name,name);
	strcpy(this->pwd,pwd);
	this->role = prole;
}

Staff::~Staff()
{
}

char *Staff::getName()
{
	return this->name;
}

char *Staff::getPwd()
{
	return this->pwd;
}

int Staff::getRole()
{
	return this->role;
}

10.CData.h .cpp【公共数据类】

#ifndef CDATA_H
#define CDATA_H
#include"CStaff.h"

//程序的所有的公共的数据
//程序开始 读取文件获取数据到CData
//无需创建对象直接类名::函数名();
//静态数据成员 类名::数据成员名
class CData
{
public:
	//静态数据成员  属于类
	static Staff* staffArr[10];
	static int staffCount;//只初始化一次
	//菜谱数据
	//台桌数据
	//员工数据
protected:
private:
};

#endif
#include"CData.h"

//类的静态成员的初始化
//数据类型  类名::数据成员名
Staff*CData::staffArr[10]=
{
  new Staff(1001,"admin","123456",ADMIN),
  new Staff(1002,"manager","123456",MANAGER),
  new Staff(1003,"waiter","123456",WAITER)
};
int CData::staffCount=3;//初始化3个人

11.CIndexWin.h .cpp【管理员窗口】

#ifndef CINDEXWIN_H
#define CINDEXWIN_H
#include"CWinBase.h"//继承窗口基类
#include"CButton.h"
#include "CLabel.h"
#include"CEdit.h"

class CIndexWin:public CWinBase
{
public:
	CIndexWin();
	~CIndexWin();
	CIndexWin(int x,int y,int w,int h);
	int doAction();
protected:
private:
    CLabel *titleguan;
	CButton *btntaizhuo ,*btncaipu,*btnrenyuan,*btnzhuxiao,*btntuichu;
};

#endif
#include"CIndexWin.h"
#include"CTools.h"
#include<iostream>
using namespace std;

CIndexWin::CIndexWin():CWinBase()
{
}

CIndexWin::~CIndexWin()
{
}

CIndexWin::CIndexWin(int x,int y,int w,int h)
:CWinBase(x,y,w,h)
{
    this->titleguan = new CLabel(21,7,10,2,"管理员界面",LABEL);//0	
	this->btntaizhuo = new CButton(19,9,8,3,"台桌管理",BUTTON);//1
	this->btncaipu = new CButton(19,12,8,3,"菜谱管理",BUTTON); //2
	this->btnrenyuan = new CButton(19,15,8,3,"人员管理",BUTTON);//3
	this->btnzhuxiao = new CButton(19,18,8,3,"注销",BUTTON); //4
	this->btntuichu = new CButton(19,21,8,3,"退出",BUTTON);//5
	
	this->addControl(this->titleguan);
   	this->addControl(this->btntaizhuo);
	this->addControl(this->btncaipu);
	this->addControl(this->btnrenyuan);
	this->addControl(this->btnzhuxiao);
	this->addControl(this->btntuichu);	 
}

int CIndexWin::doAction()
{
	switch(this->focusIndex)
	{
	case 5:
		return 0;  //到初始界面
	default:
		break;	
	}
	return 1;//0
}

12.CManagerWin.h .cpp【经理窗口】

#ifndef CMANAGERWIN_H
#define CMANAGERWIN_H
#include"CWinBase.h"//继承窗口基类
#include"CButton.h"
#include "CLabel.h"
#include"CEdit.h"

class CManagerWin:public CWinBase
{
public:
	CManagerWin();
	~CManagerWin();
	CManagerWin(int x,int y,int w,int h);
	int doAction();
protected:
private:
    CLabel *titlemanager;
	CButton *btnyingshou ,*btnzhuxiao,*btntuichu;
};

#endif
#include"CManagerWin.h"
#include"CTools.h"
#include<iostream>
using namespace std;

CManagerWin::CManagerWin():CWinBase()
{
}

CManagerWin::~CManagerWin()
{
}

CManagerWin::CManagerWin(int x,int y,int w,int h)
:CWinBase(x,y,w,h)
{
	this->titlemanager = new CLabel(21,7,10,2,"经理功能界面",LABEL);//0
	this->btnyingshou = new CButton(19,9,8,3,"营收汇总",BUTTON);    //1
	this->btnzhuxiao = new CButton(19,12,8,3,"注销",BUTTON);        //2
	this->btntuichu = new CButton(19,15,8,3,"退出",BUTTON);         //3

	this->addControl(this->titlemanager);
   	this->addControl(this->btnyingshou);
	this->addControl(this->btnzhuxiao);
	this->addControl(this->btntuichu);
}

int CManagerWin::doAction()
{
	switch(this->focusIndex)
	{
	case 3:  
		return 0;  //到初始界面
	default:
		break;	
	}
	return 1;//0
}

13.CWaiterWin.h .cpp【服务员窗口】

#ifndef CWAITERWIN_H
#define CWAITERWIN_H
#include"CWinBase.h"//继承窗口基类
#include"CButton.h"
#include "CLabel.h"
#include"CEdit.h"

class CWaiterWin:public CWinBase
{
public:
	CWaiterWin();
	~CWaiterWin();
	CWaiterWin(int x,int y,int w,int h);
	int doAction();
protected:
private:
    CLabel *titlewaiter;
	CButton *btnkaizhuo ,*btndiancai,*btnyingyee,*btnyimai ,*btnzhuxiao,*btntuichu;
};

#endif
#include"CWaiterWin.h"
#include"CTools.h"
#include<iostream>
using namespace std;

CWaiterWin::CWaiterWin():CWinBase()
{
}

CWaiterWin::~CWaiterWin()
{
}

CWaiterWin::CWaiterWin(int x,int y,int w,int h)
:CWinBase(x,y,w,h)
{
	this->titlewaiter = new CLabel(21,7,10,2,"服务员功能界面",LABEL); //0
	this->btnkaizhuo = new CButton(19,9,10,3,"开桌",BUTTON);          //1
	this->btndiancai = new CButton(19,12,10,3,"点菜",BUTTON);         //2
	this->btnyingyee = new CButton(19,15,10,3,"营业额查询",BUTTON);   //3
	this->btnyimai = new CButton(19,18,10,3,"已买/未买单查询",BUTTON);//4
	this->btnzhuxiao = new CButton(19,21,10,3,"注销",BUTTON);         //5
	this->btntuichu = new CButton(19,24,10,3,"退出",BUTTON);          //6
	
	this->addControl(this->titlewaiter);
   	this->addControl(this->btnkaizhuo);
	this->addControl(this->btndiancai);
	this->addControl(this->btnyingyee);
	this->addControl(this->btnyimai);
	this->addControl(this->btnzhuxiao);
	this->addControl(this->btntuichu);
}

int CWaiterWin::doAction()
{
	switch(this->focusIndex)
	{
	case 6:
		return 0;  //到初始界面
	default:
		break;	
	}
	return 1;//0
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

chenruhan_QAQ_

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值