Advertisement
Guest User

Untitled

a guest
Aug 4th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.98 KB | None | 0 0
  1. #include <cstdio>
  2. #include <cstdlib>
  3. #include <iostream>
  4. #include <string>
  5.  
  6. using namespace std;
  7.  
  8. void doit(void);
  9. void handleCommand(string cmd);
  10.  
  11. // The current user's credentials.
  12. string USER;
  13. string PASS;
  14.  
  15. // An Account class that holds their balance, first and last names,
  16. // and their PIN number.
  17. class Account
  18. {
  19. public:
  20.     // Deposits money into this account.
  21.     void deposit(double amt)
  22.     {
  23.         balance += amt;
  24.     }
  25.  
  26.     // Account holder's first and last name.
  27.     string firstName;
  28.     string lastName;
  29.  
  30.     // Account number. Example: 1034
  31.     unsigned accountNumber;
  32.  
  33.     // Account balance. Example: 134.50 $
  34.     double balance;
  35. };
  36.  
  37. // The Bank class which stores accounts.
  38. class Bank
  39. {
  40. public:
  41.     // Counts the amount of accounts in use at this Bank.
  42.     int countAccounts()
  43.     {
  44.         int count = 0;
  45.  
  46.         // Loop through each account.
  47.         for each(Account acc in accounts)
  48.         {
  49.             // Check if there is no name assigned.
  50.             if(acc.firstName._Mysize != 0)
  51.             {
  52.                 count++;
  53.             }
  54.         }
  55.         return count;
  56.     }
  57.  
  58.     // This Bank's accounts. Maximum ammount of 10.
  59.     Account accounts[10];
  60. };
  61.  
  62. // Access-point to the application.
  63. int main(int numArgs, char* args[])
  64. {
  65.     // Fire welcome message.
  66.     cout << "Welcome to Bank Server T-One." << endl;
  67.     cout << "Please enter your username and password to begin." << endl << endl;
  68.  
  69.     // Ask for and receive username.
  70.     cout << "Enter your username: ";
  71.     getline(cin, USER);
  72.  
  73.     // Ask for and receive password.
  74.     cout << "Enter your password: ";
  75.     getline(cin, PASS);
  76.  
  77.     // Do an account credential check.
  78.     if(USER == "admin" && PASS == "mypass")
  79.     {
  80.         cout << "Welcome " << USER << "!" << endl;
  81.     } else
  82.     {
  83.         cout << "Login failed! Invalid username or password." << endl;
  84.         system("pause");
  85.         return 0;
  86.     }
  87.  
  88.     doit();
  89.  
  90.     system("pause");
  91.     return 0;
  92. }
  93.  
  94. // A simple blocking call.
  95. void doit(void)
  96. {
  97.     // Listen for commands until the user enters the 'quit' command.
  98.     while(true)
  99.     {
  100.         string cmd;
  101.  
  102.         cout << "> ";
  103.         getline(cin, cmd);
  104.  
  105.         if(cmd == "quit")
  106.         {
  107.             cout << "Goodbye." << endl;
  108.             break;
  109.         }
  110.     }
  111. }
  112.  
  113. void handleCommand(string cmd)
  114. {
  115.  
  116. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement