ATM
结构体的代码
`typedef struct{
int uid;//卡号
int password;//密码
float balance; //余额
bool flag; //该账户是否存在,存在为true
}account;
vector
检测方法
bool check(account N){ bool flag = true; if (N.uid-first > base.size() || !N.flag) { printf("抱歉您所寻找的账户并不存在,请重新输入:\n"); flag = false; } if (!N.flag) { printf("抱歉您所寻找的账户已注销,请重新输入:\n"); flag = false; } return flag; }
初始化
`void init(account &N){
//设置卡号
int id = int(base.size());
N.uid = first+id; //六位卡号
printf("您的卡号为: %d \n",N.uid);
//设置密码
printf("请设置您的密码:\n");
int psw = 0;
scanf("%d",&psw);
N.password = psw; //账户密码
//初始化余额
N.balance = 0; //账户余额
//将账户标记为存在,没有被注销
N.flag = true;
}`
开户
void create(){ account N; init(N); base.push_back(N); }
注销
`//销户
void cancel(){
printf("请输入您需要删除的账号卡号:\n");
int id = 0;
scanf("%d",&id);
while (check(base[id-first]) == false) {
scanf("%d",&id);
}
printf("请输入该 %d 账号的密码:\n",id);
int psw = 0;
scanf("%d",&psw);
while (psw != base[id-first].password) {
printf("抱歉,您输入的密码并不正确,请重新输入:\n");
scanf("%d",&psw);
}
printf("您是否确认注销该账户?\t 输入1为确认注销,输入0为不注销\n");
int choice = 0;
cin>>choice;
if (choice == 1) {
base[id-first].flag = false; //flag标记为账户不存在
} else {
printf("您已取消本次注销行为\n");
}
}
`
查询
`
//查询余额
void enquire(){
printf("请输入您的账户卡号:\n");
int id = 0;
scanf("%d",&id);
while (check(base[id-first]) == false) {
scanf("%d",&id);
}
if (base[id-first].balance == 0) {
printf("很抱歉,您当前并未有任何存款\n");
} else {
printf("您的余额为: %f ¥\n",base[id-first].balance);
}
}
`
存款
`//存款
void deposit(){
printf("请输入您的账户卡号:\n");
int id = 0;
scanf("%d",&id);
while (check(base[id-first]) == false) {
scanf("%d",&id);
}
float input = 0;
printf("请输入您要存入的金额数目\n");
scanf("%f",&input);
base[id-first].balance += input;
printf("您的余额为: %f ¥\n",base[id-first].balance);
}
`
取款
`
void withdraw(){
printf("请输入您的账户卡号:\n");
int id = 0;
scanf("%d",&id);
while (check(base[id-first]) == false) {
scanf("%d",&id);
}
float input = 0;
printf("请输入您要取出的金额数目\n");
scanf("%f",&input);
if (base[id-first].balance < input) {
printf("抱歉,您的存款不足,不能取出\n");
} else {
base[id-first].balance -= input;
printf("您的余额为: %f ¥\n",base[id-first].balance);
}
}
`
转账
`
void transfer(){
printf("请输入您的账户卡号:\n");
int oid = 0;
scanf("%d",&oid);
while (check(base[oid-first]) == false) {
scanf("%d",&oid);
}
printf("请输入您所要转入的账户卡号:\n");
int iid = 0;
scanf("%d",&iid);
while (check(base[oid-first]) == false) {
scanf("%d",&oid);
}
float input = 0;
printf("请输入您要转出的金额数目\n");
scanf("%f",&input);
if (base[oid-first].balance < input) {
printf("抱歉,您的存款不足,不能转出\n");
} else {
base[oid-first].balance -= input;
base[iid-first].balance += input;
printf("您的余额为: %f ¥\n",base[oid-first].balance);
printf("对方余额为: %f ¥\n",base[iid-first].balance);
}
}
`
菜单
`
void menu(){
int end = 0; //是否结束,0记为不结束
do {
printf("请选择您需要进行的操作:\n1.开户\t2.销户\n3.查询当前余额\n4.存款\t5.取款\n6.转账\t0.退出\n");
int choose = 0;
scanf("%d",&choose);
switch (choose) {
case 0:
printf("Bye~\n");
exit(0);
case 1:
create();
break;
case 2:
cancel();
break;
case 3:
enquire();
break;
case 4:
deposit();
break;
case 5:
withdraw();
break;
case 6:
transfer();
break;
default:
break;
}
printf("请问您是否需要继续进行其他操作?输入1继续进行其他操作,输入0则退出\n");
scanf("%d",&end);
} while (end);
}
`



| psp | 任务内容 | 计划完成时间(min) | 实际完成时间(min) |
|---|---|---|---|
| Planning | 计划 | 10 | 5 |
| Estimate | 估计任务时间并规划大概步骤 | 10 | 5 |
| Design | 设计 | 180 | 200 |
| Code Review | 代码复审 | 5 | 10 |
| Coding Standard | 代码规范 | 3 | 2 |
| Design | 具体设计 | 10 | 12 |
| Coding | 具体编码 | 36 | 21 |
| Code Review | 代码复审 | 15 | 7 |
| Test | 测试(自我测试,修改代码,提交修改) | 10 | 15 |
| Reporting | 报告 | 30 | 40 |
| Test Report | 测试报告 | 40 | 50 |
| Size Measurement | 计算工作量 | 30 | 20 |
| Postmortem & Process | Improvement Plan 事后总结,并提出过程改进计划 | 30 | 30 |
浙公网安备 33010602011771号