资源描述
二、应用分析题
应用面向对象技术分析一在职职工医疗保险管理系统,用来对职工的个人医保帐户进行管理,系统的需求为:
1. 每个职工有一个唯一的帐号,记录该职工的帐上余额。个人每月交纳的保险金额为工资的2%,单位为个人每月交纳的保险金额为工资的7%。
2. 每个职工有一个IC卡,有密码,并与职工的个人帐户相关联。每次就医后可凭卡支付医疗费用,IC卡可挂失、重发,如何时候都只有一张卡有效。
3. 系统要记录每次交纳医疗保险金的往来帐,并能查询打印这些信息。
4. 系统要记录每次支付医疗保险金的往来帐,并能查询打印这些信息。系统不能透支。
5. 不考虑对个人工资的管理、个人所属单位的管理。但要考虑入保和退保的处理。
系统分析设计与编程要求为:
1. 分析系统的对象集合,得出系统的类集合。
2. 完成系统所有类的属性的定义。
3. 完成系统所有类的服务定义。
4. 确定系统类之间的结构与连接关系。
5. 采用半展开方式进行主题划分。
6. 完成一个用例图的描述,以及一个类的编程实现。
1. 由问题要求可知系统对象集合包括:职工、IC卡、统计簿,故该系统中应包含的类有:职工类、IC卡类、统计簿类。
2. 职工类包含的属性有:账号、姓名、工资、医保卡余额、IC卡
IC卡类包含的属性有:密码、账号、状态
统计簿类包含的属性有:员工数、员工医保花销
3. 职工类包含的方法有:入保、退保、就医、获取余额、计算结余
IC卡类包含的方法有:设置密码、获取卡号、支付、挂失、重发、注销
统计簿类包含的方法有:查询、打印
4. 系统类之间的结构和联系图
5. 半展开主题图
1. 职工信息
职工
IC卡
2. 交纳记录
IC卡
统计簿
3. 外部接口
查询
打印
6. 用例图描述
7.运行结果:
8.程序代码:
#include <string>
#include <iostream>
using namespace std;
//IC卡类
class ICcard
{
private:
long number;//IC卡卡号
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 differ!"<<endl;
}
//退出医保
void retreat()
{
state=false;
number--;
}
//获取IC卡卡号
long getNumber()
{
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;//IC卡
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;
}
}
}
};
//测试
void main()
{
Statistics s=Statistics();
s.queryAndPrint();
}
PS:请于1月13日中午12时之前交到 356856127@ ,格式 学号-姓名,我收到会回复
如有问题,请联系 李玮15996314016
9
展开阅读全文