-
Notifications
You must be signed in to change notification settings - Fork 0
/
InterfaceStringVector.cpp
70 lines (62 loc) · 1.75 KB
/
InterfaceStringVector.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
//
// Created by Vasiliy Evdokimov on 05.06.2020.
//
#include <iostream>
#include "InterfaceStringVector.hpp"
#include "StringVector.hpp"
void InterfaceStringVector(){
StringV s = "";
StringV option = "";
std::cin >> s;
std::cout << s;
while(true){
std::cout << "Menu : \n"
"1. Concatenate\n"
"2. Add symbol\n"
"3. Erase symbol\n"
"4. Get symbol\n"
"5. Get size\n"
"6. Quit\n";
std::cin >> option;
if (option == "1"){
StringV s2 = "";
std::cout << "Enter string : ";
std::cin >> s2;
s = s + s2;
}
else if (option == "2"){
char c = '\0';
size_t pos = 0;
std::cout << "Enter new symbol : ";
std::cin >> c;
std::cout << "Enter his position : ";
std::cin >> pos;
s.InsertAt(pos, c);
}
else if (option == "3"){
size_t pos = 0;
std::cout << "Enter position you want to delete : ";
std::cin >> pos;
s.EraseAt(pos);
}
else if (option == "4"){
size_t pos = 0;
std::cout << "Enter position you want to check : ";
std::cin >> pos;
std::cout << s[pos];
}
else if (option == "5"){
std::cout << s.GetSize();
}
else if (option == "6"){
break;
}
else {
std::cout << "\n****"
" Incorrect input. "
"Please read instructions carefully and try again! **** \n\n";
continue;
}
std::cout << s;
}
}