#include<iostream>
#include<cstring>
using namespace std;
//Employee class
class Employee {
public:
Employee(int new_num, char* new_name, double new_basicSal, double new_prize); // Employee class constructor declaration
void Show(); //Output basic information of employee categories
double OutputWage1(); //Return to employee salary
void ShowSalary(); // Print employee salary
private:
int num; //serial number
char name[18]; //Name
double basicSal; //Basic salary
double prize; //bonus
};
//Initialization of employee class constructor
Employee::Employee(int new_num, char* new_name, double new_basicSal, double new_prize){
num = new_num;
strcpy(name, new_name);
basicSal = new_basicSal;
prize = new_prize;
}
// Output basic employee information
void Employee::Show() {
cout << "serial number:" << num << endl;
cout << "Name:" << name << endl;
cout << "Basic salary:" << basicSal << "Yuan" << endl;
cout << "bonus:" << prize << "Yuan" << endl;
}
//Return to the actual salary of the employee
double Employee::OutputWage1(){
double salary;
//The actual salary of employees = basic salary + bonus
salary = basicSal + prize;
return salary;
}
void Employee::ShowSalary(){
cout << "Real salary:" << OutputWage1() << "Yuan" << endl;
}
//Salesperson
class Saleman :virtual public Employee {
public:
Saleman(int a, char* b, double d, double e, double f, double g);
void Output2();//Output Employee+Saleman Basic information
void output2(); // Only output Saleman basic information
double OutputWage2();
void ShowSalary();
private:
double daductRatr; //Member sales commission ratio
double personAmount;//Personal sales
};
Saleman::Saleman(int new_num, char* new_name, double new_basicSal, double new_prize, double new_daductRatr, double new_personAmount) :Employee(new_num, new_name, new_basicSal, new_prize){
daductRatr = new_daductRatr;
personAmount = new_personAmount;
}
//Output Employee+Saleman Basic information
void Saleman::Output2() {
Show();
cout << "Salesperson commission ratio:" << daductRatr << endl;
cout << "Personal Sales:" << personAmount << "Yuan" << endl;
}
// Only output Saleman basic information
void Saleman::output2() {
cout << "Salesperson commission ratio:" << daductRatr << endl;
cout << "Personal Sales:" << personAmount << "Yuan" << endl;
}
//Return to the actual salary of the salesperson
double Saleman::OutputWage2() {
double salary;
//Salesperson's actual salary = basic salary + bonus * Attendance rate + personal sales * Salesperson commission ratio
salary = Employee::OutputWage1() + personAmount * daductRatr;
return salary;
}
void Saleman::ShowSalary(){
cout << "Real salary:" << OutputWage2() << "Yuan" << endl;
}
//Manager
class Manager :virtual public Employee {
public:
Manager(int new_num, char* new_name, double new_basicSal, double new_prize, double new_totalDeductRate, double new_totalAmount);
void Output3();//Output Employee+Manager Basic Information
void output3();//Only output the basic information of Manager
double OutputWage3();//Return to the manager's actual salary
void ShowSalary();
private:
double totalDeductRate;
double totalAmount;
};
Manager::Manager(int new_num, char* new_name, double new_basicSal, double new_prize, double new_totalDeductRate, double new_totalAmount) :Employee(new_num, new_name, new_basicSal, new_prize){
totalDeductRate = new_totalDeductRate; //Manager commission ratio
totalAmount = new_totalAmount;//Total sales
}
//Output Employee+Manager Basic Information
void Manager::Output3() {
Show();
cout << "Manager commission ratio:" << totalDeductRate << endl;
cout << "Total Sales:" << totalAmount << "Yuan" << endl;
}
//Only output the basic information of Manager
void Manager::output3() {
cout << "Manager commission ratio:" << totalDeductRate << endl;
cout << "Total Sales:" << totalAmount << "Yuan" << endl;
}
//Return to the manager's actual salary
double Manager::OutputWage3() {
double salary;
//The manager's actual salary = basic salary + bonus + total sales * Manager's commission ratio
salary = Employee::OutputWage1() + totalAmount * totalDeductRate;
return salary;
}
void Manager::ShowSalary(){
cout << "Real salary:" << OutputWage3() << "Yuan" << endl;
}
//Sales Manager
class SaleManager :public Saleman, public Manager {
public:
SaleManager(int new_num, char* new_name, int new_basicSal, int new_prize, double f, double g, double h, double i);
void Output4();//Output basic information of sales manager
double OutputWage4();//Return to the actual salary of the sales manager
void ShowSalary();
};
SaleManager::SaleManager(int new_num, char* new_name, int new_basicSal, int new_prize, double new_daductRatr, double new_personAmount, double new_totalDeductRate, double new_totalAmount) :
Saleman(new_num, new_name, new_basicSal, new_prize, new_daductRatr, new_personAmount), Manager(new_num, new_name, new_basicSal, new_prize, new_totalDeductRate, new_totalAmount), Employee(new_num, new_name, new_basicSal, new_prize) {
}
void SaleManager::Output4() {
Employee::Show();
Saleman::output2();
Manager::output3();
}
//Return to the actual salary of the sales manager
double SaleManager::OutputWage4() {
double salary;
//The sales manager's actual salary = basic salary + bonus + personal sales * salesperson commission ratio + total sales * manager commission ratio
salary = Saleman::OutputWage2() + Manager::OutputWage3() - Employee::OutputWage1();
return salary;
}
void SaleManager::ShowSalary(){
cout << "Real salary:" << OutputWage4() << "Yuan" << endl;
}
int main() {
//staff
Employee e(106, "Li Ming", 1680, 1080); // Define the object
cout << "Employee Information:" << endl; // Output prompt
e.Show(); // Output basic information
e.ShowSalary(); // Export real salary
cout << "" << endl;
//Salesperson
Saleman s(108, "Li Jieming", 2680, 1680, 0.15, 23000); // Define the object
cout << "Salesperson information:" << endl; // Output prompt
s.Output2(); // Output basic information
s.ShowSalary(); // Export real salary
cout << "" << endl;
//manager
Manager m(116, "Wu Qian", 3680, 2680, 0.1, 83000); // Define the object
cout << "Manager information:" << endl; // Output prompt
m.Output3(); // Output basic information
m.ShowSalary(); // Export real salary
cout << "" << endl;
//Sales Manager s4
SaleManager sm(118, "Wu Jie", 3680, 2680, 0.15, 28000, 0.1, 88000); // Define the object
cout << "Sales Manager Information:" << endl; // Output prompt
sm.Output4(); // Output basic information
sm.ShowSalary(); // Export real salary
return 0; // Return value, return to operating system
}