Skip to content

Commit

Permalink
add:Assignment,Cipher,Dichpher
Browse files Browse the repository at this point in the history
  • Loading branch information
muhibarshad committed Oct 28, 2022
1 parent a6059f3 commit a5bdc26
Show file tree
Hide file tree
Showing 12 changed files with 290 additions and 11 deletions.
11 changes: 0 additions & 11 deletions Challenge Yourself Here/Labs/Lab-section-A/lab_05_OOP/task1.cpp
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 not shown.
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 not shown.
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 not shown.
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;
}
Binary file added Projects/Bankist_App/CIpher_DICPher/main
Binary file not shown.
102 changes: 102 additions & 0 deletions Projects/Bankist_App/CIpher_DICPher/main.cpp
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;
}

0 comments on commit a5bdc26

Please sign in to comment.