-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
90 lines (80 loc) · 2.5 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
81
82
83
84
85
86
87
88
89
90
#include <iostream>
#include "stock.hpp"
#include "course.hpp"
using namespace std;
//TODO: переписать более эффективно
int main()
{
Stock obj = Stock();
bool running = 1;
while (running)
{
cout << "[LAB]> ";
string command;
cin >> command;
cout << endl;
if (command == "add")
{
Course nc = Course();
nc.read_from_console();
obj.add(nc);
cout << endl;
}
else if (command == "pop")
{
int c;
cout << "Введите индекс удаляемого элемента: ";
cin >> c;
obj.pop(c);
}
else if (command == "read_from_json")
{
string path;
cout << "Введите путь к файлу" << endl;
cin >> path;
obj.read_from_json(path);
cout << endl;
}
else if (command == "write_to_json")
{
string path;
cout << "Введите путь к файлу" << endl;
cin >> path;
obj.write_to_json(path);
cout << endl;
}
else if (command == "print_all")
{
obj.print_all();
cout << endl;
}
else if (command == "print_exp")
{
obj.print_exp();
cout << endl;
}
else if (command == "help")
{
cout << "Список доступных комманд: " << endl;
cout << "add - добавить в контейнер" << endl;
cout << "pop - убрать из контейнера" << endl;
cout << "read_from_json - ввести несколько из JSON (перезапись)" << endl;
cout << "write_to_json - сохранить всё в JSON" << endl;
cout << "print_all - вывести все" << endl;
cout << "get_cnt - получить количество" << endl;
cout << "help - список команд" << endl;
cout << "exit - выход" << endl << endl;
}
else if (command == "exit")
{
cout << "Выход" << endl;
running = 0;
}
else
{
cout << "Неверная комманда" << endl;
cout << "Для получения списка комманд введите help" << endl;
}
}
return 0;
}