-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
80 lines (79 loc) · 1.62 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#include <iostream>
#include <fstream>
#include "cilent.h"
using namespace std;
extern Goods g[MAX_NUM];
extern int total;
int main()
{
ifstream fin ("in.txt");
if(!fin.is_open())
{
cout << " \b文件打开失败,请重试" << endl;
exit (1);
}
fin >> total;
for(int i = 0; i < total; ++i)
{
fin >> g[i].name >> g[i].count; //将文件中的数据放入结构体数据中
}
fin.close();
int choice;
string name;
while(choice = welcome()) //选择对应的功能 若为0便退出
{
switch(choice)
{
case 1:
{
if(save_goods())
{
cout << "\b 存入成功" << endl;
if(flash_list())
{
cout << "\b列表更新成功!" << endl;
}
}
else
cout << "\b 存入失败" << endl;
break;
}
case 2:
{
if(get_goods())
{
cout << "\b 取出成功" << endl;
if(flash_list())
{
cout << "\b列表更新成功!" << endl;
}
}
else
cout << "\b 取出失败" << endl;
break;
};break;
case 3:
{
cout << "\b输入查询的的物品英文名字【单词间请用下划线隔开】" << endl;
cin>>name;
int temp = find_goods(name);
if(temp == -1) //说明仓库中没有该物品
{
cout << "\b没有找到该商品" << endl;
}
else if(temp < total) //说明仓库中有该类商品,直接修改数量即可
{
cout << g[temp].name << " " << g[temp].count << endl;
}
else //find_goods返回意料之外的值,报告错误
{
cout << "\b查询时出现预料之外的错误" << endl;
}
break;
}
case 4:show_goods();break;
};
cout << endl << endl;
//刷新缓冲区
}
}