-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMetodyPomocnicze.cpp
More file actions
90 lines (76 loc) · 2.02 KB
/
MetodyPomocnicze.cpp
File metadata and controls
90 lines (76 loc) · 2.02 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
#include "MetodyPomocnicze.h"
char MetodyPomocnicze::wczytajZnak() {
string wejscie = "";
char znak = {0};
while (true)
{
getline(cin, wejscie);
if (wejscie.length() == 1)
{
znak = wejscie[0];
break;
}
cout << "To nie jest pojedynczy znak. Wpisz ponownie." << endl;
}
return znak;
}
int MetodyPomocnicze::konwersjaStringNaInt(string liczba)
{
int liczbaInt;
istringstream iss(liczba);
iss >> liczbaInt;
return liczbaInt;
}
string MetodyPomocnicze::konwerjsaIntNaString(int liczba) {
ostringstream ss;
ss << liczba;
string str = ss.str();
return str;
}
string MetodyPomocnicze::pobierzLiczbe(string tekst, int pozycjaZnaku) {
string liczba = "";
while(isdigit(tekst[pozycjaZnaku]) == true) {
liczba += tekst[pozycjaZnaku];
pozycjaZnaku ++;
}
return liczba;
}
string MetodyPomocnicze::wczytajLinie() {
string wejscie = "";
getline(cin, wejscie);
return wejscie;
}
string MetodyPomocnicze::zamienPierwszaLitereNaDuzaAPozostaleNaMale(string tekst) {
if (!tekst.empty())
{
transform(tekst.begin(), tekst.end(), tekst.begin(), ::tolower);
tekst[0] = toupper(tekst[0]);
}
return tekst;
}
int MetodyPomocnicze::wczytajLiczbeCalkowita()
{
string wejscie = "";
int liczba = 0;
while (true)
{
getline(cin, wejscie);
stringstream myStream(wejscie);
if (myStream >> liczba)
break;
cout << "To nie jest liczba. Wpisz ponownie. " << endl;
}
return liczba;
}
void MetodyPomocnicze::usunPlik(string nazwaPlikuZRozszerzeniem)
{
if (remove(nazwaPlikuZRozszerzeniem.c_str()) == 0) {}
else
cout << "Nie udalo sie usunac pliku " << nazwaPlikuZRozszerzeniem << endl;
}
void MetodyPomocnicze::zmienNazwePliku(string staraNazwa, string nowaNazwa)
{
if (rename(staraNazwa.c_str(), nowaNazwa.c_str()) == 0) {}
else
cout << "Nazwa pliku nie zostala zmieniona." << staraNazwa << endl;
}