-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFramedWelcome.cpp
86 lines (58 loc) · 1.79 KB
/
FramedWelcome.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
#include <iostream>
#include <string>
#include <stdlib.h>
#ifdef _WIN32
#define WINPAUSE system("pause")
#endif
using namespace std;
string InputName();
void ModifyString(int amount, string &modifiedString, char addedSymbol);
void drawFrame();
int main()
{
// Sveikas, vardas!
// lengthOfIntro + name.length() + 1
drawFrame();
WINPAUSE;
}
void ModifyString(int amount, string &modifiedString, char addedSymbol) {
for (int i = 0; i < amount; i++)
modifiedString += addedSymbol;
}
void drawFrame() {
string name;
int lines;
cout << "Iveskite varda: ";
cin >> name;
cout << "Iveskite norima eiluciu skaiciu: ";
cin >> lines;
string greeting;
string* cardLine = new string[lines];
string edgeCharacter = "*";
if (name[name.length() - 1] == 's')
greeting = " Sveikas, " + name + "! ";
else
greeting = " Sveika, " + name + "! ";
cardLine[0] = edgeCharacter;
ModifyString(greeting.length(), cardLine[0], '*');
cardLine[0] += edgeCharacter;
for (int i = 1; i <= lines / 2; i++) {
cardLine[i] = "*";
ModifyString(greeting.length(), cardLine[i], ' ');
cardLine[i] += "*";
}
cardLine[lines / 2] = edgeCharacter;
cardLine[lines / 2] += greeting;
cardLine[lines / 2] += edgeCharacter;
for (int i = lines / 2 + 1; i <= lines - 1; i++) {
cardLine[i] = "*";
ModifyString(greeting.length(), cardLine[i], ' ');
cardLine[i] += "*";
}
cardLine[lines-1] = edgeCharacter;
ModifyString(greeting.length(), cardLine[lines-1], '*');
cardLine[lines-1] += edgeCharacter;
for (int i = 0; i < lines; i++)
cout << cardLine[i] << endl;
delete[] cardLine;
}