-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a6059f3
commit a5bdc26
Showing
12 changed files
with
290 additions
and
11 deletions.
There are no files selected for viewing
11 changes: 0 additions & 11 deletions
11
Challenge Yourself Here/Labs/Lab-section-A/lab_05_OOP/task1.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +0,0 @@ | ||
#include <iostream> | ||
|
||
using namespace std; | ||
|
||
int main() | ||
{ | ||
|
||
char *arr = "abc"; | ||
cout << *arr << "\n"; | ||
return 0; | ||
} | ||
Binary file added
BIN
+17.5 KB
Challenge Yourself Here/SmartPractice/Operator_Overloading/AggregationComposition/task1
Binary file not shown.
39 changes: 39 additions & 0 deletions
39
Challenge Yourself Here/SmartPractice/Operator_Overloading/AggregationComposition/task1.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#include <iostream> | ||
|
||
using namespace std; | ||
|
||
class List | ||
{ | ||
private: | ||
int *list=nullptr; | ||
int count; | ||
|
||
public: | ||
List(const int &count) : count(count) | ||
{ | ||
list = new int[count]; | ||
for (int i = 0; i < count; i++) | ||
{ | ||
list[i] = (rand() % (99 - 10) + 1) + 10; | ||
} | ||
} | ||
friend ostream& operator <<(ostream& out,const List& list ) | ||
{ | ||
out<<"The elements in the List :\n"; | ||
for(int i=0;i<list.count;i++) | ||
{ | ||
out<<list.list[i]<<"\n"; | ||
} | ||
return out; | ||
} | ||
~List() | ||
{ | ||
delete list; | ||
} | ||
}; | ||
int main() | ||
{ | ||
List list1(10); | ||
cout<<list1; | ||
return 0; | ||
} |
Binary file added
BIN
+17.8 KB
Challenge Yourself Here/SmartPractice/Operator_Overloading/AggregationComposition/task2
Binary file not shown.
62 changes: 62 additions & 0 deletions
62
Challenge Yourself Here/SmartPractice/Operator_Overloading/AggregationComposition/task2.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#include <iostream> | ||
|
||
using namespace std; | ||
|
||
class List | ||
{ | ||
private: | ||
int *list = nullptr; | ||
int count; | ||
|
||
public: | ||
List(const int &count) : count(count) | ||
{ | ||
list = new int[count]; | ||
for (int i = 0; i < count; i++) | ||
{ | ||
list[i] = (rand() % (99 - 10) + 1) + 10; | ||
} | ||
} | ||
friend ostream &operator<<(ostream &out, const List &list) | ||
{ | ||
for (int i = 0; i < list.count; i++) | ||
{ | ||
out << list.list[i] << " "; | ||
} | ||
return out; | ||
} | ||
~List() | ||
{ | ||
delete list; | ||
} | ||
}; | ||
class fiveLists | ||
{ | ||
private: | ||
List *five[5]; | ||
|
||
public: | ||
fiveLists() | ||
{ | ||
for (int i = 0; i < 5; i++) | ||
five[i] = new List{(rand() % (5 - 10) + 1) + 5}; | ||
} | ||
void show() | ||
{ | ||
for (int i = 0; i < 5; i++) | ||
{ | ||
cout << *(five[i]) << "\n"; | ||
} | ||
} | ||
~fiveLists() | ||
{ | ||
for (int i = 0; i < 5; i++) | ||
delete five[i]; | ||
} | ||
}; | ||
int main() | ||
{ | ||
fiveLists l; | ||
l.show(); | ||
return 0; | ||
} |
Binary file added
BIN
+17.9 KB
Challenge Yourself Here/SmartPractice/Operator_Overloading/AggregationComposition/task3
Binary file not shown.
87 changes: 87 additions & 0 deletions
87
Challenge Yourself Here/SmartPractice/Operator_Overloading/AggregationComposition/task3.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
#include<iostream> | ||
|
||
using namespace std; | ||
class List | ||
{ | ||
private: | ||
int *list = nullptr; | ||
int count; | ||
|
||
public: | ||
List(const int &count) : count(count) | ||
{ | ||
list = new int[count]; | ||
for (int i = 0; i < count; i++) | ||
{ | ||
list[i] = (rand() % (99 - 10) + 1) + 10; | ||
} | ||
} | ||
friend ostream &operator<<(ostream &out, const List &list) | ||
{ | ||
for (int i = 0; i < list.count; i++) | ||
{ | ||
out << list.list[i] << " "; | ||
} | ||
return out; | ||
} | ||
~List() | ||
{ | ||
delete list; | ||
} | ||
}; | ||
class fiveLists_ | ||
{ | ||
private: | ||
List* arr[5]; | ||
public: | ||
fiveLists_() | ||
{ | ||
for(int i=0;i<5;i++) | ||
arr[i]=nullptr; | ||
} | ||
void addList(int listnumber,int size) | ||
{ | ||
arr[listnumber]=new List{size}; | ||
} | ||
void removeList(int listNumber) | ||
{ | ||
delete arr[listNumber]; | ||
arr[listNumber]=nullptr; | ||
} | ||
void show() | ||
{ | ||
for(int i=0;i<5;i++) | ||
{ | ||
if(arr[i]!=nullptr) | ||
{ | ||
cout<<*(arr[i])<<"\n"; | ||
} | ||
else | ||
{ | ||
cout<<"Empty List "<<i<<"\n"; | ||
} | ||
} | ||
} | ||
~fiveLists_() | ||
{ | ||
for(int i=0;i<5;i++) | ||
{ | ||
if(arr[i]!=nullptr) | ||
{ | ||
delete arr[i]; | ||
} | ||
} | ||
} | ||
|
||
}; | ||
int main() | ||
{ | ||
fiveLists_ list1; | ||
list1.addList(0,5); | ||
list1.addList(2,10); | ||
list1.addList(4,15); | ||
list1.removeList(2); | ||
list1.show(); | ||
|
||
return 0; | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
#include <iostream> | ||
#include <conio.h> | ||
#include <windows.h> | ||
#include <fstream> | ||
using namespace std; | ||
|
||
void spaces() | ||
{ | ||
for (int i = 0; i < 3; i++) | ||
{ | ||
cout << endl; | ||
} | ||
} | ||
int display() | ||
{ | ||
spaces(); | ||
int n; | ||
cout << "\t\t\tEnter 1 to Encrypt the message" << endl; | ||
cout << "\t\t\tEnter 2 to Decrypt the messege" << endl; | ||
cin >> n; | ||
while (n != 1 && n != 2) | ||
{ | ||
cout << "Invalid Input! Enter AGAIN: "; | ||
cin >> n; | ||
} | ||
cout << endl; | ||
system("cls"); | ||
return n; | ||
} | ||
void print(char *chArr, const int &size) | ||
{ | ||
for (int i = 0; i < size; i++) | ||
{ | ||
cout << chArr[i]; | ||
} | ||
cout << endl; | ||
} | ||
void encryptMessage(char *&chArr, int &size) | ||
{ | ||
char ch; | ||
do | ||
{ | ||
ch = getch(); | ||
char *temp = new char[size + 1]; | ||
for (int i = 0; i < size; i++) | ||
{ | ||
temp[i] = chArr[i]; | ||
} | ||
temp[size - 1] = ch; | ||
temp[size] = '\0'; | ||
size++; | ||
delete[] chArr; | ||
chArr = temp; | ||
system("cls"); | ||
spaces(); | ||
cout << "\t\t\t Enter the message:\n\n\n\t\t"; | ||
|
||
print(chArr, size); | ||
} while (ch != 13); | ||
} | ||
|
||
int main() | ||
{ | ||
int event = display(); | ||
ofstream out; | ||
ifstream in; | ||
switch (event) | ||
{ | ||
case 1: | ||
{ | ||
spaces(); | ||
cout << "\t\t\t Enter the message :"; | ||
int size = 1; | ||
int code; | ||
char *chArr = new char[size]{'\0'}; | ||
encryptMessage(chArr, size); | ||
spaces(); | ||
cout << "\t\t\t Enter your encrepted code :\n\t\t\t"; | ||
cin >> code; | ||
|
||
cout << "\t\t\t Encrpyting......\n"; | ||
out.open("encrypted.txt"); | ||
for (int i = 0; i < size; i++) | ||
{ | ||
char temp=chArr[i] + ((987%89)*700)%34+56; | ||
out << temp; | ||
} | ||
|
||
// Sleep(3 * 1000); | ||
system("cls"); | ||
spaces(); | ||
cout << "\t\t\t Your Message encrypted Successfully.\n"; | ||
break; | ||
} | ||
case 2: | ||
{ | ||
break; | ||
} | ||
} | ||
|
||
return 0; | ||
} |