南邮硕士研究生OOADP作业

应用面向对象技术分析一在职职工医疗保险管理系统,用来对职工的个人医保帐户进行管理,系统的需求为:

1. 每个职工有一个唯一的帐号,记录该职工的帐上余额。个人每月交纳的保险金额为工资的2%,单位为个人每月交纳的保险金额为工资的7%

2. 每个职工有一个IC卡,有密码,并与职工的个人帐户相关联。每次就医后可凭卡支付医疗费用,IC卡可挂失、重发,如何时候都只有一张卡有效。

3. 系统要记录每次交纳医疗保险金的往来帐,并能查询打印这些信息。

4. 系统要记录每次支付医疗保险金的往来帐,并能查询打印这些信息。系统不能透支。

5. 不考虑对个人工资的管理、个人所属单位的管理。但要考虑入保和退保的处理。

系统分析设计与编程要求为:

1. 分析系统的对象集合,得出系统的类集合。

2. 完成系统所有类的属性的定义。

3. 完成系统所有类的服务定义。

4. 确定系统类之间的结构与连接关系。

5. 采用半展开方式进行主题划分。

6. 完成一个用例图的描述,以及一个类的编程实现。

详细设计见:http://wenku.baidu.com/link?url=cZ6xH5bHn4CMssZTRXC0RqsVYPq86dGvij0_zpimdeq6_OeCMBFE005-jgohac9xdBuDogG-aQKrp4bRUjJbfiACebFVduF-JpPR-LstNgC


#include <iostream>
#include <string>
using namespace std;

class ICcard  //IC卡类
{
private:
	long number;
	char password[6];
	bool state; //是否加入医保或挂失
public:
	ICcard()
	{
		state=true;
		number++;
	}
	void setPassword()
	{
		cout<<"please input your password length of 6"<<endl;
		string str1,str2;
		cin>>str1;
		cout<<"please again"<<endl;
		cin>>str2;
		if(str1==str2)
		{
			for(int i=0;i<6;i++)
				password[i]=str1[i];
		}
		else
			cout<<"password error!"<<endl;
	}
	void retreat() //退出医保
	{
		state=false;
		number--;
	}
	long getNumber() //获取IC卡卡号
	{
		return number;
	}
	void drop()  //挂失
	{
		state=false;
	}
	void redistribute()
	{
		state=true;
	}
	float pay(float expend)
	{
		if(state=true)
			return expend;
	}
};

class Employee  //职工类
{
private:
	string name;
	ICcard *iccard;
	float salary;
	float medicalSaving;
	long id;
public:
	Employee()
	{
	}
	Employee(string name,float salary)
	{
		this->name=name;
		this->salary=salary;
	}
	void join()	 //入保
	{
		iccard=new ICcard();    
		id=iccard->getNumber()+100000;  
		iccard->setPassword();  
		medicalSaving=salary*0.09;
	}
	void quit()	  //退保
	{
		cout<<"you have to drop out the system,we will call back the ICcard "<<endl;
		iccard->retreat();
	}
	void consume(float expend)
	{
		medicalSaving-=iccard->pay(expend);
	}
	float getBalance()
	{
		return medicalSaving;
	}
	string getName()
	{
		return name;
	}
	~Employee()
	{
		delete iccard;
	}
};

class Statistics  //统计本
{
private:
	Employee *person[3];
	float expend[3];
public:
	Statistics()
	{
		for(int i=0;i<3;i++)
		{
			string str;
			float salary;
			float expends;
			cout<<"please input Employee "<<i<<" 's name and salary and consume  amount"<<endl;    
			cin>>expends>>str>>salary;    
			expend[i]=expends;     
			person[i]=new Employee(str,salary);    
			person[i]->join();     
			person[i]->consume(expends);
		}
	}
	void queryAndPrint()
	{
		cout<<"please input the person's name who you want to query"<<endl;   
		string str;   
		cin>>str;    
		for(int i=0;i<3;i++)   
		{    
			if(str==person[i]->getName())    
			{     
				cout<<"you got it at person["<<i<<"]"<<endl;     
				cout<<"his related information is as follows:"<<endl;         
				cout<<"his consume this time is "<<expend[i]<<endl; 
				cout<<"the balance is "<<person[i]->getBalance()<<endl; 
			}
		}
	}
};
int main()
{
	Statistics s=Statistics();
	s.queryAndPrint();
	return 0;
}
测试结果:


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值