Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ros-Meher Narula #75

Open
wants to merge 30 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
0134815
Add files via upload
MeherNarula May 11, 2024
4eb23fb
Add files via upload
MeherNarula May 11, 2024
78c104e
Add files via upload
MeherNarula May 11, 2024
1c746bf
Update Firstassignoopsreadme.md
MeherNarula May 11, 2024
6788bb0
Merge branch 'AerialRobotics-IITK:main' into ONLINE-BANKING-CLIENT
MeherNarula Jun 14, 2024
73b4acb
Add files via upload
MeherNarula Jun 14, 2024
95c76f4
Update ROS_Assign1_readme.md
MeherNarula Jun 14, 2024
0209aa9
Update ROS_Assign1_readme.md
MeherNarula Jun 14, 2024
8f3b046
Update ROS_Assign1_readme.md
MeherNarula Jun 14, 2024
cd7e3f0
Add files via upload
MeherNarula Jun 14, 2024
fca91bc
Rename Screenshot from 2024-06-14 22-00-25.png to screenshot of the t…
MeherNarula Jun 14, 2024
b96242b
Rename screenshot of the two terminals to screenshot of the two termi…
MeherNarula Jun 14, 2024
1debfd4
Create First-Assignment
MeherNarula Jun 22, 2024
6e7fb4d
Delete First-Assignment
MeherNarula Jun 22, 2024
dfdd781
Create this_is_empty
MeherNarula Jun 22, 2024
eaaf46e
Update and rename Firstassignoops.cpp to First -Assignment/Firstassig…
MeherNarula Jun 22, 2024
c75c866
Update and rename Firstassignoopsreadme.md to First -Assignment/First…
MeherNarula Jun 22, 2024
2bf3a0a
Create ROS
MeherNarula Jun 22, 2024
42151f5
Delete ROS
MeherNarula Jun 22, 2024
4a5c2d3
Update and rename ROS_Assign1_readme.md to ROS/ROS_Assign1_readme.md
MeherNarula Jun 22, 2024
26aaa96
Rename screenshot of the two terminals.png to ROS/screenshot of the t…
MeherNarula Jun 22, 2024
209884f
Create ROS_assign2,3,4
MeherNarula Jun 22, 2024
60679bd
Add files via upload
MeherNarula Jun 22, 2024
beaf53a
Rename ROS_assign2,3,4 to ROS_assign2,3,4.md
MeherNarula Jun 22, 2024
b735691
Update ROS_assign2,3,4.md
MeherNarula Jun 22, 2024
067adda
Update ROS_assign2,3,4.md
MeherNarula Jun 22, 2024
c9b70ad
Add files via upload
MeherNarula Jun 22, 2024
06e0a67
Update ROS_assign2,3,4.md
MeherNarula Jun 22, 2024
889cb2b
Update ROS_assign2,3,4.md
MeherNarula Jun 23, 2024
bb9dcc4
Update ROS_assign2,3,4.md
MeherNarula Jun 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions First -Assignment/First_assignment_readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@

># Online Banking System
>-We have defined a global list accounts of type Bankaccntholder to keep track of all people making an account in the bank
>- we import the chrono header file and so that we can measure time since epoch , convert it into an integer secondsValue and use it further in calculation of interest rate

>## Defining Bankaccntholder class
>
> - we have mainly two functions changepassword() and getaccount()
> - the get() function is used to set username and password as they are private members and cannot be directly accessed .
> - and there is a pointer function o link BankAccount class to Bankaccntholder

>## Defining its functions
> -changepassword helps to enumerate among all accounts by matching username to reach the account we are talking about and then helps to change the password to the one taken as inout from the user
>- setaccountdetails helps to link the person to a bankaccount


>## Definig BankAccount class

>-it has three functions transfer,deposit and withdraw
> -it has a list of string type called transaction which keeps track of transactions made in the account
> - it also has function getbalance to be able to retrieve the balance in the account at any given time


>## Derived classes : Savingsaccount and Checkingaccount
>-we earlier madebalance as a protected member so that it can be acessed by both these account types
>-we define constructor in both accounts
>- We also use bool value of isopen to close the accounts
>- Interest Rate for saving account is dependent on balance and the time spent since opening of the account


># We define Bankaccntholder
> - We define the functions needed .
> - We create a list ownaccounts of the accounts unnder the banking account that the user has made
> - in getAccountNumber() we return accountDetails as a pointer pointing to the Accountnumber of Bankaccount
> -under createaccount we declare a new bankaccount and a bankaccountholder
> - we try to set the opening balance ,, username and password of this bank account
> - if the bank account doesnt already exist , we ensure that by enumeratin through alll accountds and comparing username to ensure uniqueness.
> - if the account a;ready exists we try to compare and find it from our list of accounts
> - there is also a failsafe in place using while(1) which ensures in case no such account exists with the help of the flag value we are able to identify that
> -we set accountnumber in order of the bankaccounts being formed
> -we include BAH in the list of accounts
> -We ask if they want to open a savings or current account and then push_back said account into the ownaccounts list


>## We define Branch Manager

> - we create it as a singleton object
> - we make the branch manager a static instance pointer which is not changed in creation of multiple objects and remains the same
> -initialy instance is a nullptr
> - function fastforwarrd skips days on which the iinterestrate is dependent
>



341 changes: 341 additions & 0 deletions First -Assignment/Firstassignment.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,341 @@
#include<iostream>
#include<list>
#include<string>
#include<chrono>
using namespace std ;



const auto now = std::chrono::system_clock::now();
// Transform the time into a duration since the epoch
const auto epoch = now.time_since_epoch();
// Cast the duration into seconds
auto seconds = std::chrono::duration_cast<std::chrono::seconds>(epoch);

// Convert seconds to integer
int secondsValue = static_cast<int>(seconds.count());
int balancecap= 10000000;


class BankAccount {
public:
int transfer();
int deposit();
int withdraw();
int getBalance();
int Accountnumber;
int opendate;
protected:
int balance;
list<string> transaction;
};

int BankAccount::deposit(){
int deposit;
cout <<"Write the amount you want to deposit"<<endl;
return balance+deposit;
}

int BankAccount::withdraw(){
int withdraw;
cout <<"Write the amount you want to deposit"<<endl;
return balance-withdraw;
}

int BankAccount::getBalance(){
return balance;
}

class Savingaccount : BankAccount {
int interestrate;
public:
bool isopen;
int getInterestRate();
Savingaccount();
void closeSavingaccount();
void setInterestRate(int rate);

};

void Savingaccount::closeSavingaccount( ){
string response;
std::cout<<"Do you want to close this bank account. Reply in Y/N"<<endl;
std::cin >> response ;
if (response=="Y"){
isopen = false ;
}
}

int Savingaccount::getInterestRate(){
interestrate = 0.0000000000001*balance + 0.006*(secondsValue/(3600*24)) ;
if (interestrate<6){
return interestrate;
}
else {
return 6;
}
}

Savingaccount::Savingaccount(){
isopen = true ;
std::cout<<"New Savingaccount account created."<<endl;
}

void Savingaccount::setInterestRate(int rate){
interestrate=rate;
}
class Currentaccount:BankAccount{
int interestrate;
public:
bool isopen;
void closeCurrentaccount();
int getInterestRate();
Currentaccount();
};

void Currentaccount::closeCurrentaccount( ){
string response ;
std::cout<<"Do you want to close this bank account. Reply in Y/N"<<endl;
std::cin >> response ;
if (response=="Y"){
isopen = false ;
}
}

int Currentaccount::getInterestRate(){
return interestrate;
}


Currentaccount::Currentaccount(){
std::cout<<"New Currentaccount account created."<<endl;
}



class Bankaccntholder{
public:
void get(string pass , string user);
void changepassword();
void createaccount() ;
void setAccountDetails(BankAccount* accnt) ;
int getAccountNumber();
list<Savingaccount> getownaccounts();
list<Currentaccount> getownaccounts2();
BankAccount* accountDetails;
string password;
string username;
string name ;
string setpass();
string setuser();


private:
list<Savingaccount> ownaccounts;
list<Currentaccount> ownaccounts2;
string username;
string Netbankingpass;



};

list<Bankaccntholder> accounts;

int Bankaccntholder::getAccountNumber() {
if (accountDetails) {
return accountDetails->Accountnumber;
}
return -1; // Indicate no account associated
}

void Bankaccntholder::changepassword(){
string username , password ;
cout <<"what is your username ?"<<endl;
cin>>username;
cout<<"what do you want to change the password to ?"<<endl;
cin>>password;
for (auto& account : accounts) {
if (account.username == username) {
account.password = password;
break;
}
}
}


void Bankaccntholder::setAccountDetails(BankAccount* accnt) {
accountDetails = accnt;
}

list<Savingaccount> Bankaccntholder::getownaccounts(){
return ownaccounts;
}


list<Currentaccount> Bankaccntholder::getownaccounts2(){
return ownaccounts2;
}

void Bankaccntholder::get(string pass,string user){
password = pass;
username = user ;
}



void Bankaccntholder::createaccount(){

int point=0;
Bankaccntholder BAH;
BankAccount BA;
std::cout<<"Do you already have an account ? Type Y/N"<<endl;
string ans;
std::cin>>ans;
std::cout<<"Please type in username password "<<endl;
string user,pass;
std::cin >> user >> pass;
std::cout<<"Please type in opening Bank Balance "<<endl;
while(1){
int balance ;
int flag=0;
std::cin >> balance ;
if (balance>balancecap){
cout<<"You are exceeding maximum allowed balance in a bank account "<<endl;
flag++;
}
if(flag==0){break;}

}
if (ans=="N"){

while(1){
int flag=0;
for (const auto& account : accounts) {

if (user == account.username ){
std::cout<<"Such an account already exists . Enter new username ."<<endl;
flag++;
break;

}


} if(flag==0){break;}
std::cout<<"Please type in username password "<<endl;
string user,pass;
std::cin >> user >> pass;
std::cout<<"Please type in opening Bank Balance "<<endl;
while(1){
int balance ;
int flag=0;
std::cin >> balance ;
if (balance>balancecap){
cout<<"You are exceeding maximum allowed balance in a bank account "<<endl;
flag++;
}
if(flag==0){break;}

}
}

if (point==0){
BAH.get(pass,user);
BA.Accountnumber= accounts.size() + 1 ;
point++;
accounts.push_back(BAH);

}

else{
int flag = 0 ;
for (const auto& account : accounts) {
if (user == account.username && pass==account.password){
BAH= account;
flag++;
break;
}

}
if (flag==0){
std::cout<<"There is no such account . Please make new account.Restart the program"<<endl;
}
}






}
std::cout<<"do you want to open savings account or checking accountor not open any account "<<endl;
string reply;
std::cin>>reply;
if (reply=="savings account"){
Savingaccount SA ;
BAH.getownaccounts().push_back(SA);
}

else if(reply=="current account"){
Currentaccount CA ;
BAH.getownaccounts2().push_back(CA);
}
}




class BranchManager{
static BranchManager * Instance;
BranchManager();
std::list<BankAccount> accounts;

public:
void getbalance();
void getAccountnumber();
void fastforward(int days);
static BranchManager* getBM();
void getAccountHolders();
void getStatementofAccount();


};

BranchManager* BranchManager :: Instance=nullptr;

void BranchManager::fastforward(int days){
cout <<"How many days do you wanna skip"<<endl;
cin>>days;
secondsValue=secondsValue - days*3600;
}

BranchManager::BranchManager(){
std::cout<<"New BranchManager account created."<<endl;
}

BranchManager*BranchManager::getBM()
{
if (Instance== nullptr){
Instance=new BranchManager();
}
return Instance;
}

void BranchManager::getAccountHolders(){
std::cout << "Bank Accounts:" << endl;
for (const auto& account : accounts) {
// std::cout << "Account Number: " << account.getAccountNumber() << endl;

}
}

void BranchManager::getStatementofAccount(){
std::cout << "Bank Accounts:" << endl;
for (const auto& account : accounts) {
// std::cout << "Bank Statement: " << account.getbalance() << endl;

}

}


1 change: 1 addition & 0 deletions First -Assignment/this_is_empty
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Loading