您的位置:首页 > 编程语言 > C语言/C++

【c++】公司职员系统

2015-11-18 09:17 330 查看
项目要求:
http://wenku.baidu.com/link?url=7W1Xe8gGtxs-uS-idLhFEEtPg_EIwlr7IdicivC5M7aDdy-QsUWjFx-qJz3f2_Zkh51mvKAHwoOVOjvXqVpfHSJpHw1tzaLmvMCYXyzkfNi
系统分成5个类:Employee基类,包含Manager类,SalesMan类,SalesManager类,Techicians类,EmployeeManager类(管理器类),头文件代码如下(cpp文件太多了,有需要的可以私信我):

#pragma once

enum Sex
{
MALE,
FEMALE,
};

enum Department
{
DEPARTMENT_1,
DEPARTMENT_2,
DEPARTMENT_3,
DEPARTMENT_4,
};

enum EmployeeType
{
MANAGER,
TECHNICIAN,
SALESMAN,
SALESMANAGER,
};


#pragma once
#include "Enum.h"

class CEmployee
{
public:
CEmployee();
CEmployee(const CEmployee& Ep);
~CEmployee();

void SetName(const char* pstrName);
void SetNumber(const int nNumber);
void SetSex(const Sex nSex );
void SetDepartment(const Department nDep);
void SetGrade(const int nGrade);

const char* GetName() const;
const int GetNumber() const;
int GetSex() const;
int GetDepartment()const;
const int GetGrade() const;

//判断两个职员的名字是否相同
bool IsSameName(char* pName,int nNum)const;

//拷贝构造函数,深拷贝指向职员基类的指针
virtual CEmployee* Copy();
virtual double GetSalary() const;
virtual EmployeeType GetEmployeeType() const;

protected:
//初始化基类中的数据成员
void Init(int nNum,char* pstrName,Sex nSex,
Department nDepartment,int nGrade);

private:
char* m_pstrName; //职员姓名
int m_nNumber; //职员编号
Sex m_nSex; //职员性别
Department m_nDepartment; //职员所在部门
int m_nGrade; //职员级别
EmployeeType m_nET; //职员职务
};

#pragma once
#include "Employee.h"

class CManager : public CEmployee
{
public:
CManager();
//自定义构造函数
CManager(int nNum,char* pstrName,Sex nSex,
Department nDepartment,int nGrade,double m_dFixSalary);
~CManager();
//拷贝构造函数
CManager(const CManager& Mgr);

void SetFixSalary(double dSalary);

virtual double GetSalary()const;
virtual EmployeeType GetEmployeeType()const;
virtual CEmployee* Copy();

private:
double m_dFixSalary;

};
#pragma once
#include "Employee.h"

class CSalesMan : public CEmployee
{
public:
CSalesMan();
~CSalesMan();
CSalesMan(const CSalesMan& SM);
CSalesMan(int nNum,char* pstrName,Sex nSex,
Department nDepartment,int nGrade,double dSalesVolume);

void SetSalesVolume(double dSalesVolume);

virtual double GetSalary()const;
virtual EmployeeType GetEmployeeType()const;
virtual CEmployee* Copy();
private:
double m_dSalesVolume;
};

#pragma once
#include "Employee.h"

class CSalesManager : public CEmployee
{
public:
CSalesManager();
~CSalesManager();

CSalesManager(int nNum,char* pstrName,Sex nSex,
Department nDepartment,int nGrade,double dSalesVolume,double dFixSalary);
CSalesManager(const CSalesManager& SMgr);

void SetSalesVolume(double dSalesVolume);
void SetFixSalary(double dFixSalary);
virtual double GetSalary() const;
virtual EmployeeType GetEmployeeType()const;
virtual CSalesManager* Copy();
private:
double m_dSalesVolume;
double m_dFixSalary;

};

#pragma once
#include "Employee.h"

class CTechnician:public CEmployee
{
public:
CTechnician();
~CTechnician();
CTechnician(int nNum,char* pstrName,Sex nSex,
Department nDepartment,int nGrade,double dWorkTime);
CTechnician(const CTechnician& Tec);

void SetWorkTime(double dWorkTime);
virtual double GetSalary()const;
virtual EmployeeType GetEmployeeType()const;
virtual CTechnician* Copy();
private:
double m_dWorkTime;

};
#pragma once
#include "stdafx.h"
#include <vector>
#include "Manager.h"
#include "SalesMan.h"
#include "Technicians.h"
#include "SalesManager.h"

using namespace std;

class CEmployeeManager
{
public:
CEmployeeManager();
~CEmployeeManager();
CEmployeeManager(CEmployeeManager& EmpMgr);

//增删查方法
void Add(CEmployee* pE);
void Delete(const int nIndex);
CEmployee* Find(char* strName) const;

//获取容器中第i(nIndex)个容器
CEmployee* GetEmployee(int nIndex);
CEmployeeManager* Copy();
//将管理器中的数据拷贝到另一管理器中
void CopyTo(CEmployeeManager*)const;

//获得容器中职员个数
int GetSize();
//获取容器中上次选中职员的在容器中的位置
int GetPreSel()const;
//设置容器中下次选中职员在容器中的位置
void SetPreSel(int nIndex);
//删除容器及其中的指针
void DeleteVector();
//仅删除容器中的指针
void Clear();

private:
std::vector <CEmployee*>     m_vEM;    //职员管理器指针
int                          m_nPreSel;//记录对话框中上次选中的职员
};


注:本文也是初学者,希望大家能共同学习!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: