Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <random>
- using namespace std;
- class BankAccount {
- private:
- string bankNumber;
- string bankName;
- string ownerName;
- double balance;
- public:
- BankAccount() {
- this->bankNumber = "null";
- this->bankName = "null";
- this->ownerName = "null";
- this->balance = 0.0;
- }
- BankAccount(string bankNumber, string bankName, string ownerName, double balance) {
- this->bankNumber = bankNumber;
- this->bankName = bankName;
- this->ownerName = ownerName;
- this->balance = balance;
- }
- //get
- string getBankNumber() { return this->bankNumber; }
- string getBankName() { return this->bankName; }
- string getOwnerName() { return this->ownerName; }
- double getBalance() { return this->balance; }
- //set
- void setBankNumber(string number) { this->bankNumber = number; }
- void setBankName(string bankName) { this->bankName = bankName; }
- void setOwnerName(string ownerName) { this->ownerName = ownerName; }
- void setBalance(double balance) { this->balance = balance; }
- // Abstract
- void deposit(double value) { this->balance += value; }
- void withdraw(double value) { this->balance -= value; }
- void generate() {
- string names[4] = { "Toshko", "Goshko", "Chochko", "Neshto" };
- string bankNames[4] = { "DSK", "BNB", "RBB", "CCB" };
- //////////////////////////////////////////////////////////////////
- // Random Generating //
- //////////////////////////////////////////////////////////////////
- random_device rd;
- mt19937 gen(rd());
- //////////////////////////////////////////////////////////////////
- uniform_int_distribution<> random_names(0, 4);
- uniform_int_distribution<> random_banks(0, 4);
- uniform_int_distribution<> random_bank_number(100000, 999999);
- uniform_real_distribution<> random_balance(0.0, 1000.0);
- //////////////////////////////////////////////////////////////////
- this->bankNumber = to_string(random_bank_number(gen));
- this->bankName = bankNames[random_banks(gen)];
- this->ownerName = names[random_names(gen)];
- this->balance = random_balance(gen);
- }
- void print_info() {
- cout << "Bank Number: " << this->bankNumber << endl;
- cout << "Bank Name: " << this->bankName << endl;
- cout << "Owner Name: " << this->ownerName << endl;
- cout << "Balance: " << this->balance << endl;
- }
- };
- int main() {
- BankAccount acc;
- acc.generate();
- acc.print_info();
- cout << endl;
- acc.withdraw(15);
- acc.print_info();
- return 0;
- }
Add Comment
Please, Sign In to add comment