PSP数据统计
PSP2.1 |
Personal Software Process Stages |
预估耗时 |
Planning |
计划 |
\ |
· Estimate |
· 估计这个任务需要多少时间 |
10h |
Development |
开发 |
\ |
· Analysis |
· 需求分析 (包括学习新技术) |
2h |
· Design Spec |
· 生成设计文档 |
10min |
· Design Review |
· 设计复审 (和同事审核设计文档) |
0 |
· Coding Standard |
· 代码规范 (为目前的开发制定合适的规范) |
10min |
· Design |
· 具体设计 |
30min |
· Coding |
· 具体编码 |
4h |
· Code Review |
· 代码复审 |
30min |
· Test |
· 测试(自我测试,修改代码,提交修改) |
30min |
Reporting |
报告 |
\ |
· Test Report |
· 测试报告 |
30min |
· Size Measurement |
· 计算工作量 |
10min |
· Postmortem & Process Improvement Plan |
· 事后总结, 并提出过程改进计划 |
10min |
|
合计 |
|
项目代码
1 #include <iostream> 2 #include<string> 3 4 using namespace std; 5 6 #define MAX 1000 7 struct Goods{ //物品结构体 8 string name; 9 string owner; 10 string phone_number; 11 }; 12 13 struct arrayGoods{ //物品清单结构体 14 struct Goods goods[MAX]; 15 int num; 16 }; 17 18 void mean(){ //菜单栏 19 20 cout << "***************************" << endl; 21 cout << "****疫情互助物品交换系统***" << endl; 22 cout << "*******1、添加物品*********" << endl; 23 cout << "*******2、删除物品*********" << endl; 24 cout << "*******3、显示物品列表*****" << endl; 25 cout << "*******4、查找物品信息*****" << endl; 26 cout << "*******0、退出系统*********" << endl; 27 cout << "****************************" << endl; 28 29 } 30 31 int outSystem(){ //退出系统 32 cout<<"欢迎下次使用"<<endl; 33 return 0; 34 } 35 36 int isExist(arrayGoods *aG, string name){ //判断物品是否在物品清单中存在 37 for(int i=0; i < aG->num; i++){ 38 if(aG->goods[i].name == name){ 39 return i; 40 } 41 } 42 return -1; 43 } 44 45 void addGoods(arrayGoods *aG){ //添加物品 46 if(aG->num >= MAX){ 47 cout<<"当前物品列表已满,请删除已取出物品后再进行添加"<<endl; 48 } 49 else{ 50 string name; 51 cout<<"请输入物品名称"<<endl; 52 cin>>name; 53 aG->goods[aG->num].name=name; 54 55 int flag = isExist(aG,name); //判断添加的物品是否已经存在 56 if(flag == -1){ 57 string owner; 58 cout<<"请输入物主姓名"<<endl; 59 cin>>owner; 60 aG->goods[aG->num].owner=owner; 61 62 string phone_number; 63 cout<<"请输入物主联系方式"<<endl; 64 cin>>phone_number; 65 aG->goods[aG->num].phone_number=phone_number; 66 67 aG->num++; 68 69 cout<<"添加成功"<<endl; 70 } 71 else{ 72 cout<<"同类物品已存在"<<endl; 73 } 74 } 75 } 76 77 void deleteGoods(arrayGoods *aG){ //删除物品 78 cout<<"请输入你要删除的物品"<<endl; 79 string name; 80 cin>>name; 81 82 int flag = isExist(aG,name); 83 if(flag != -1){ 84 for(int i= 0;i+flag < aG->num; ++i){ 85 aG->goods[flag+i].name=aG->goods[flag+i+1].name; 86 aG->goods[flag+i].owner=aG->goods[flag+i+1].owner; 87 aG->goods[flag+i].phone_number=aG->goods[flag+i+1].phone_number; 88 aG->num--; 89 } 90 cout<<"删除成功"<<endl; 91 }else{ 92 cout<<"查无此物"<<endl; 93 } 94 } 95 96 void showGoods(arrayGoods *aG){ //展示物品清单 97 if(aG->num == 0){ 98 cout<<"物品清单为空"<<endl; 99 } 100 else{ 101 for(int i = 0; i < aG->num; ++i){ 102 cout<<"物品名称: "<<aG->goods[i].name<<"\t"; 103 cout<<"物品主人: "<<aG->goods[i].owner<<"\t"; 104 cout<<"联系方式: "<<aG->goods[i].phone_number<<endl; 105 } 106 } 107 } 108 109 void checkGoods(arrayGoods *aG){ //查找物品 110 cout<<"请输入你要查找的物品名称"<<endl; 111 string name; 112 cin>>name; 113 114 int flag = isExist(aG,name); 115 if(flag != -1){ 116 cout<<"物品名称: "<<aG->goods[flag].name<<"\t"; 117 cout<<"物品主人: "<<aG->goods[flag].owner<<"\t"; 118 cout<<"联系方式: "<<aG->goods[flag].phone_number<<endl; 119 }else{ 120 cout<<"查无此物"<<endl; 121 } 122 } 123 124 125 int main() 126 { 127 int x; 128 arrayGoods aG; 129 aG.num=0; 130 131 while(true){ 132 mean(); 133 cin>>x; 134 switch(x){ 135 case 1: 136 addGoods(&aG); 137 break; 138 case 2: 139 deleteGoods(&aG); 140 break; 141 case 3: 142 showGoods(&aG); 143 break; 144 case 4: 145 checkGoods(&aG); 146 break; 147 case 0: 148 outSystem(); 149 break; 150 151 } 152 153 } 154 155 return 0; 156 }
标签:goods,name,软件开发,number,flag,num,aG,我助,homework From: https://www.cnblogs.com/WJYwang/p/16732121.html