Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /******************************************************************************
- LEONARDO T.M. VIEIRA
- A NEW BANK
- *******************************************************************************/
- #include <iostream>
- #include <locale.h>
- #include <cstdlib>
- #include<time.h>
- #include<ctype.h>
- #include<string>
- using namespace std;
- class BA
- {
- public:
- string verify= "You don't have enough money!";
- string warm= "Maximum value!(400)";
- int client;
- void set_money(int j)
- {
- money=j;
- }
- int get_money()
- {
- return money;
- }
- BA (string something)
- {
- money= data_name(something);
- }
- ~BA ()
- {
- }
- void credit (int value)
- {
- if (warning(value))
- {
- money=value+money;
- cout<<", your new balance is:"<<endl;
- cout<<get_money()<<endl;
- }
- else
- {
- cout<<", Please, try another different value."<<endl;
- cout<<warm<<endl;
- }
- }
- void debit (int x)
- {
- if (verification(x))
- {
- cout<<", your new balance is:"<<endl;
- money=money-x;
- cout<<get_money()<<endl;
- }
- else
- {
- cout<<", please, try another different value."<<endl;
- cout<<"\n"<<verify<<"\n";
- }
- }
- private:
- int money;
- int data_name(string something)
- {
- int pop=0;
- int i;
- std::getline(std:: cin, something);
- for (i=0; i<something.length(); i++)
- {
- pop+=(int)something[i];
- }
- return pop;
- }
- int warning (int value)
- {
- if (value>400)
- {
- return 0;
- }
- else
- {
- return 1;
- }
- }
- int verification (int x)
- {
- if (money>=x)
- {
- return 1;
- }
- else
- {
- return 0;
- }
- }
- };
- int main()
- {
- char option;
- int u;
- int v;
- char D;
- string something;
- cout<<"Welcome to the bank!!!"<<endl;
- cout<<"\nWhat's your name?"<<endl;
- std::getline(std:: cin, something);
- BA b (something);
- BA b1 (something);
- cout<<"\nPlease, press an option bellow"<<endl;
- do
- {
- cout<<"[A,B,C,0]"<<endl;
- cout<<"\n\tA=showing your money\n\tB=adding credit in your account (maximum 400),\n\tC=debiting from your account \n\tD= close your bank account"<<endl;
- cin>> option;
- if (option=='a'||option=='b'||option=='c'||option=='d')
- {
- option=toupper(option);
- }
- switch(option)
- {
- case 'A':
- {
- cout<<"\n"<<something;
- cout<<", your balance is:"<<endl;
- cout<<b.get_money()<<endl;
- break;
- }
- case 'B':
- {
- cout<<"How much do you want to credit?"<<endl;
- cin>>v;
- cout<<"\n"<<something;
- b.credit(v);
- break;
- }
- case 'C':
- {
- cout<<"How much do you want to debit?"<<endl;
- cin>>u;
- cout<<"\n"<<something;
- b.debit(u);
- break;
- }
- default:
- if (option=D)
- {
- cout<<"\n"<<something;
- cout<<", you've closed your bank account. Thanks for coming today!"<<endl;
- system("cls");
- cout<<"Welcome to the bank!!!"<<endl;
- cout<<"\nWhat's your name?"<<endl;
- cin>>something;
- //std::getline(std:: cin, name);
- }
- else
- {
- cout<<"\n"<<something;
- cout<<", please, insert an option bellow"<<endl;
- }
- }
- }
- while(b1.client!=2);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement