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

📄 salesman.h

📁 利用虚函数定义工人信息
💻 H
字号:
class salesmanager:virtual public manager,virtual public salesman{
private:
	float total;int no1,no2,no3,no4;char name1[8],name2[8],name3[8],name4[8];
	float sale1,sale2,sale3,sale4;
public:
	int flag;
	void salemanager(){
		monthlypay=5000;
		commrate=0.005;
	}
	void input(){cout<<"销售经理";employee::input();}
	void save(){
		fstream outfile;
		outfile.open("F:shuju.txt",ios::app);
		if(!outfile){
			cout<<"f can't open.\n";
			abort();
		}
		outfile<<"销售经理"<<endl;
		outfile<<"号码"<<no<<"名字"<<name<<"性别"<<sex<<"年龄"<<age<<"工资"<<salary<<endl;
	}
	void savesale(){
		fstream outfile;
		outfile.open("F:shuju.txt",ios::app);
		if(!outfile){
			cout<<"F can't open.\n";
			abort();
		}
		outfile<<"销售经理所辖售员业绩及自己的工资"<<endl;
		outfile<<"编号"<<no1<<"名字"<<name1<<"工资"<<sale1<<endl;
		outfile<<"编号"<<no2<<"名字"<<name2<<"工资"<<sale2<<endl;
		outfile<<"编号"<<no3<<"名字"<<name3<<"工资"<<sale3<<endl;
		outfile<<"编号"<<no4<<"名字"<<name4<<"工资"<<sale4<<endl;
	}
	int min(float salary1,float salary2){
		if(salary1<salary2)
			return 1;
		else return 2;
	}
	void pay(){
		salemanager();
		salary=monthlypay+commrate*totalsale();
	}
	float totalsale(){
		total=sale1+sale2+sale3+sale4;return total;
	}
	void printtotal(){
		cout<<"├—————┴——┬——┴—————┤"<<endl;
		cout<<"│销售额合计 │ "<<setw(10)<<total<<" │"<<endl;
		cout<<"└————————┴————————┘"<<endl;
	}
	void sort(salesmanager &p){
		int tmp,i,j;
		for(j=0;j<2;j++)
			for(i=0;i<2;i++)
				if(total<p.salary){
					tmp=salary;
					total=p.salary;
					p.salary=tmp;
					tmp=no;
					no=p.no;
					p.no=tmp;
				}
	}
	void saler(){
		cout<<name<<"所管部门月销售量:";
		cout<<"职工编号:";
		cin>>no1;
		cout<<" 职工姓名:";
		cin>>name1;
		cout<<" 销售额:";
		cin>>sale1;
		cout<<"职工编号:";
		cin>>no2;
		cout<<" 职工姓名:";
		cin>>name2;
		cout<<" 销售额:";
		cin>>sale2;
		cout<<"职工编号:";
		cin>>no3;
		cout<<" 职工姓名:";
		cin>>name3;
		cout<<" 销售额:";
		cin>>sale3;
		cout<<"职工编号:";
		cin>>no4;
		cout<<" 职工姓名:";
		cin>>name4;
		cout<<" 销售额:";
		cin>>sale4;
	}
	void saleprint(){
		cout<<"│"<<setw(10)<<no1<<"│"<<setw(10)<<name1<<"│"<<setw(10)<<sale1<<"│"<<endl;
		cout<<"├—————┼—————┼—————┤"<<endl;
		cout<<"│"<<setw(10)<<no2<<"│"<<setw(10)<<name2<<"│"<<setw(10)<<sale2<<"│"<<endl;
		cout<<"├—————┼—————┼—————┤"<<endl;
		cout<<"│"<<setw(10)<<no3<<"│"<<setw(10)<<name3<<"│"<<setw(10)<<sale3<<"│"<<endl;
		cout<<"├—————┼—————┼—————┤"<<endl;
		cout<<"│"<<setw(10)<<no4<<"│"<<setw(10)<<name4<<"│"<<setw(10)<<sale4<<"│"<<endl;
	}
	void print(){
		cout<<"├—————┼—————┼—————┼—————┼—————┤"<<endl;
		cout<<"│"<<setw(10)<<no<<"│"<<setw(10)<<name<<"│"<<setw(10)<<sex<<"│"
			<<setw(10)<<age<<"│"<<setw(10)<<salary<<"│"<<endl;
	}
};

⌨️ 快捷键说明

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