-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAidMan.cpp
More file actions
119 lines (113 loc) · 2.28 KB
/
Copy pathAidMan.cpp
File metadata and controls
119 lines (113 loc) · 2.28 KB
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/*
==================================================
Mile Stone 2
==================================================
Name : Sangwoo Shin
ID : 119294213
Email : sshin36@myseneca,ca
Section: NCC
Date : 2022/3/15
*/
// I have done all the coding by myself and only copied the code that my professor provided to complete my workshops and assignments.
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstring>
#include "AidMan.h"
#include "Date.h"
using namespace std;
namespace sdds
{
AidMan::AidMan() : Menu()
{
fileName = nullptr;
option = 7;
option = "1- List Items\n2- Add Item\n3- Remove Item\n4- Update Quantity\n5- Sort\n6- Ship Items\n7- New/Open Aid Database\n---------------------------------\n";
}
int AidMan::menu() const
{
int select;
if (fileName)
{
cout << "Aid Management System Version 0.1" << endl;
cout << "Date: " << Date() << endl;
cout << "Data file: " << fileName << endl;
}
else
{
cout << "Aid Management System Version 0.1" << endl;
cout << "Date: " << Date() << endl;
cout << "Data file: No file" << endl;
}
cout << "---------------------------------" << endl;
select = option.Menu::run();
return select;
}
void AidMan::searchList(const char* menu, int select)
{
char list[30];
int menuLen = 0;
int count = 0;
int j = 0;
menuLen = strlen(option.getMenuContent());
if (select > 0)
{
for (int i = 0; i < menuLen; i++)
{
if (option.getMenuContent()[i] == '\n')
{
count++;
if (count == select)
{
list[j] = '\0';
i = strlen(option.getMenuContent());
}
}
if (count == select - 1)
{
list[j] = option.getMenuContent()[i];
j++;
}
}
if (select == count)
{
cout << "\n****";
if (select == 1)
{
for (int i = 3; list[i] != '\0'; i++)
{
cout << list[i];
}
}
else
{
for (int i = 4; list[i] != '\0'; i++)
{
cout << list[i];
}
}
cout << "****\n" << endl;
}
}
}
void AidMan::run()
{
int select = 0;
AidMan test;
do
{
select = test.menu();
if (select == 0)
{
cout << "Exiting Program!" << endl;
}
else
{
searchList(option.getMenuContent(), select);
}
} while (select != 0);
}
AidMan::~AidMan()
{
option.clear();
}
}