This repository has been archived by the owner on Jun 3, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMAIN.CPP
78 lines (67 loc) · 1.96 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
#include <cstdlib>
#include <iostream>
#include <memory>
#include "FIGURE.H"
#include "TRIANGLE.H"
#include "RECTANGLE.H"
#include "SQUARE.H"
#include "TSTACK.H"
int main(int argc, char** argv) {
bool exitkey = false;
char firstkey;
std::shared_ptr<Figure> sptr;
TStack<Figure> cookie;
setlocale(LC_CTYPE, "rus");
std::cout << "Âñåì áîáðà!" << std::endl;
std::cout << "Ôóíêöèè:\n" << std::endl;
std::cout << "T - ââîä òðåóãîëüíèêà" << std::endl;
std::cout << "R - ââîä ïðÿìîóãîëüíèêà" << std::endl;
std::cout << "S - ââîä êâàäðàòà" << std::endl;
std::cout << "D - óäàëèòü ýëåìåíò" << std::endl;
//std::cout << "A - âûâåñòè âñå ýëåìåíòû ñòåêà" << std::endl;
std::cout << "I - âûâåñòè âñå ýëåìåíòû ñòåêà" << std::endl; // Äîáàâëÿåì èòåðàòîð
std::cout << "E! - âûõîä" << std::endl << std::endl;
firstkey = '0';
while (exitkey == false) {
if (firstkey >= '0') printf("T>");
scanf_s("%c", &firstkey);
switch (firstkey) {
case 'T':
std::cout << "Ââåäèòå ïàðàìåòðû òðåóãîëüíèêà:" << std::endl;
sptr = std::make_shared<Triangle>(std::cin);
cookie.Push(sptr);
break;
case 'R':
std::cout << "Ââåäèòå ïàðàìåòðû ïðÿìîóãîëüíèêà:" << std::endl;
sptr = std::make_shared<Rectangle>(std::cin);
cookie.Push(sptr);
break;
case 'S':
std::cout << "Ââåäèòå ïàðàìåòðû êâàäðàòà:" << std::endl;
sptr = std::make_shared<SquareF>(std::cin);
cookie.Push(sptr);
break;
case 'D':
cookie.Pop();
break;
/*
case 'A':
std::cout << cookie << std::endl;
break;
*/
case 'I':
if (cookie.Empty() != true) {
for (auto tmp : cookie) tmp->Print();
} else std::cout << "Ñòåê ïóñòîé! Ñïåðâà äîáàâüòå ÷åãî-íèáóäü... ñúåäîáíîãî" << std::endl << std::endl;
break;
case 'E':
scanf_s("%c", &firstkey);
if (firstkey == '!') {
cookie.Close();
exitkey = true;
} else std::cout << "Íå ïîëó÷åíî ïîäòâåðæäåíèÿ!" << std::endl;
break;
}
}
return 0;
}