|
|
Регистрация Восстановить пароль |
Повторная активизация e-mail |
Регистрация | Задать вопрос |
Заплачу за решение |
Новые сообщения |
Сообщения за день |
Расширенный поиск |
Правила |
Всё прочитано |
|
Опции темы | Поиск в этой теме |
21.11.2019, 00:55 | #1 |
Новичок
Джуниор
Регистрация: 21.11.2019
Сообщений: 1
|
Работа банк онлайн через консоль
Может подскажет , где ошибка.
Только учусь на С++ #include <iostream> using namespace std; class Bank { public: Emploer* Workers = new Emploer[10]; Customer* Clients = new Customer[100]; }; struct Transaction { int Id; string UserName; double Amount; string Type; }; class Customer { public: string UserName; string Password; Transaction* TrxList = new Transaction[100]; void ShowBalance(); void Withdraw(); void Put(); void Swift(); Customer() :Index{ -1 } { } ~Customer() { delete[] TrxList; } private: double Balance; int Index; Transaction CreateTrx(double Amount, string Type); }; Transaction Customer::CreateTrx(double Amount, string Type) { Transaction temp; temp.Id = this->Index + 1; temp.UserName = this->UserName; temp.Amount = Amount; temp.Type = Type; this->Index++; return temp; } void Customer::ShowBalance() { cout << "Your current balance: " << this->Balance << endl; } void Customer::Withdraw() { double Amount = 0; cout << "How much would you like to Withdraw ?" << endl; cin >> Amount; if (Amount > this->Balance) { cout << "ERROR! You have not enouth funds." << endl; this->ShowBalance(); } else { Balance -= Amount; TrxList[this->Index] = this->CreateTrx(Amount, "Withdrawal"); } } void Customer::Put() { for (; { double Amount; cout << "How much you would like to put ?" << endl; cin >> Amount; if (Amount > 0) { Balance += Amount; TrxList[this->Index] = this->CreateTrx(Amount, "Put"); break; } else { cout << "Incorect amount ! Try again !" << endl; } } } class Emploer { public: string UserName; string Password; Emploer() { } Emploer(string User, string Pass) : UserName{ User }, Password{ Pass } { } void ShowTransaction(Customer& CurrentCustomer); Customer CreateClient(); }; void Emploer::ShowTransaction(Customer& CurrentCustomer) { cout << "Transaction for " << CurrentCustomer.UserName << ":" << endl; for (int i = 0; i < 100; i++) { if ((CurrentCustomer.TrxList[i].Id < 1 && CurrentCustomer.TrxList[i].Id > 100)) { cout << "Id: " << CurrentCustomer.TrxList[i].Id; cout << "User: " << CurrentCustomer.TrxList[i].UserName; cout << "Type: " << CurrentCustomer.TrxList[i].Type; cout << "Amount: " << CurrentCustomer.TrxList[i].Amount << endl; } } } Customer Emploer::CreateClient() { Customer temp; cout << "Please put Name: "; cin >> temp.UserName; cout << endl; cout << "Please put Password: "; cin >> temp.Password; cout << "User created!" << endl; } int main() { Bank* PrBank = new Bank(); PrBank->Workers[0] = Emploer("Alex", "Aa12345"); string Name; string Pass; cout << "Welcome to Privat !" << endl; cout << "User: "; cin >> Name; cout << endl; cout << "Pass: "; cin >> Pass; if (PrBank->Workers[0].UserName == Name && PrBank->Workers[0].Password == Pass) { int a; cout << "To show TRX list put 1 or put 2 to Create User" << endl; cin >> a; if (a == 1) { cin >> a; PrBank->Workers[0].ShowTransaction(PrBank->Clients[a]); } else if (a == 2) { PrBank->Clients[0] = PrBank->Workers[0].CreateClient(); } } |
22.11.2019, 21:31 | #2 |
Старожил
Регистрация: 25.08.2011
Сообщений: 2,841
|
Вы нас тренируете чтоли?
Skype - wmaster_s E-Mail - WorldMasters@gmail.com
Работаем по 3 критериям - быстро, качественно, недорого. Заказчик выбирает любые два. |
Похожие темы | ||||
Тема | Автор | Раздел | Ответов | Последнее сообщение |
Запись текста в файл через консоль | Umkass | Visual C++ | 5 | 03.11.2018 12:40 |
Программа которая находит через сколько лет вклад в банк дойдет до определенной суммы | Refuis | Паскаль, Turbo Pascal, PascalABC.NET | 0 | 21.03.2015 19:15 |
PHP: как передать параметры через консоль? | three_cats | PHP | 5 | 04.04.2013 20:10 |
Ввод и вывод данных через консоль (C++) | villain10 | Помощь студентам | 4 | 20.02.2012 22:04 |
Выключение ручной настройки TPC/IP через консоль | ATL | Операционные системы общие вопросы | 0 | 11.12.2011 15:42 |