-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUtility.cpp
More file actions
109 lines (90 loc) · 2.98 KB
/
Utility.cpp
File metadata and controls
109 lines (90 loc) · 2.98 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
// MIT License
// Copyright (c) 2025 Abiza Chiheb
// See the LICENSE file for full details.
#include <iostream>
#include "clsUtil.h"
int main()
{
clsUtil::Srand();
cout << clsUtil::RandomNumber(1, 10) << endl;
cout << clsUtil::GetRandomCharacter(clsUtil::CapitalLetter) << endl;
cout << clsUtil::GenerateWord(clsUtil::MixChars, 8) << endl;
cout << clsUtil::GenerateKey(clsUtil::MixChars) << endl;
clsUtil::GenerateKeys(10, clsUtil::MixChars);
cout << "\n";
// Swap Int
int x = 10, y = 20;
cout << x << " " << y << endl;
clsUtil::Swap(x, y);
cout << x << " " << y << endl
<< endl;
// Swap double
double a = 10.5, b = 20.5;
cout << a << " " << b << endl;
clsUtil::Swap(a, b);
cout << a << " " << b << endl
<< endl;
// Swap String
string s1 = "Ali", s2 = "Ahmed";
cout << s1 << " " << s2 << endl;
clsUtil::Swap(s1, s2);
cout << s1 << " " << s2 << endl
<< endl;
// Swap Dates
clsDate d1(1, 10, 2022), d2(1, 1, 2022);
cout << d1.DateToString() << " " << d2.DateToString() << endl;
clsUtil::Swap(d1, d2);
cout << d1.DateToString() << " " << d2.DateToString() << endl;
// Shuffl Array
// int array
int Arr1[5] = {1, 2, 3, 4, 5};
clsUtil::ShuffleArray(Arr1, 5);
cout << "\nArray after shuffle:\n";
for (int i = 0; i < 5; i++)
{
cout << Arr1[i] << endl;
}
// string array
string Arr2[5] = {"Ali", "Fadi", "Ahmed", "Qasem", "Khalid"};
clsUtil::ShuffleArray(Arr2, 5);
cout << "\nArray after shuffle:\n";
for (int i = 0; i < 5; i++)
{
cout << Arr2[i] << endl;
}
int Arr3[5];
clsUtil::FillArrayWithRandomNumbers(Arr3, 5, 20, 50);
cout << "\nArray after fill:\n";
for (int i = 0; i < 5; i++)
{
cout << Arr3[i] << endl;
}
string Arr4[5];
clsUtil::FillArrayWithRandomWords(Arr4, 5, clsUtil::MixChars, 8);
cout << "\nArray after fill:\n";
for (int i = 0; i < 5; i++)
{
cout << Arr4[i] << endl;
}
string Arr5[5];
clsUtil::FillArrayWithRandomKeys(Arr5, 5, clsUtil::MixChars);
cout << "\nArray after filling keys:\n";
for (int i = 0; i < 5; i++)
{
cout << Arr5[i] << endl;
}
cout << "\nText1 " << clsUtil::Tabs(5) << "Text2\n";
const short EncryptionKey = 2; // this is the key.
string TextAfterEncryption, TextAfterDecryption;
string Text = "Mohammed Abu-Hadhoud";
TextAfterEncryption = clsUtil::EncryptText(Text, EncryptionKey);
TextAfterDecryption = clsUtil::DecryptText(TextAfterEncryption, EncryptionKey);
cout << "\nText Before Encryption : ";
cout << Text << endl;
cout << "Text After Encryption : ";
cout << TextAfterEncryption << endl;
cout << "Text After Decryption : ";
cout << TextAfterDecryption << endl;
system("read -p '\nPress Enter to continue...'");
return 0;
}