From 7f70743cf80c4c259d348c24170db5513d25de00 Mon Sep 17 00:00:00 2001 From: Andrey Kassaev Date: Fri, 15 Mar 2024 11:15:39 +0400 Subject: [PATCH] Add project files. --- Coursework.sln | 31 +++ Coursework/Account.cpp | 1 + Coursework/Account.h | 27 ++ Coursework/AccountRequisites.cpp | 1 + Coursework/AccountRequisites.h | 24 ++ Coursework/Address.cpp | 1 + Coursework/Address.h | 30 +++ Coursework/Bank.cpp | 1 + Coursework/Bank.h | 28 ++ Coursework/BankBranch.cpp | 1 + Coursework/BankBranch.h | 29 +++ Coursework/BankRequisites.cpp | 1 + Coursework/BankRequisites.h | 77 ++++++ Coursework/CarLoan.cpp | 1 + Coursework/CarLoan.h | 41 +++ Coursework/Card.cpp | 1 + Coursework/Card.h | 34 +++ Coursework/Cash.cpp | 1 + Coursework/Cash.h | 27 ++ Coursework/ConsumerLoan.cpp | 1 + Coursework/ConsumerLoan.h | 29 +++ Coursework/Coursework.vcxproj | 187 ++++++++++++++ Coursework/Coursework.vcxproj.filters | 174 +++++++++++++ Coursework/CurrencyExchange.cpp | 1 + Coursework/CurrencyExchange.h | 39 +++ Coursework/Customer.cpp | 1 + Coursework/Customer.h | 24 ++ Coursework/Deposit.cpp | 1 + Coursework/Deposit.h | 24 ++ Coursework/Employee.cpp | 1 + Coursework/Employee.h | 44 ++++ Coursework/Enums.cpp | 1 + Coursework/Enums.h | 88 +++++++ Coursework/Insurance.cpp | 1 + Coursework/Insurance.h | 18 ++ Coursework/Investment.cpp | 1 + Coursework/Investment.h | 30 +++ Coursework/Loan.cpp | 1 + Coursework/Loan.h | 34 +++ Coursework/Main.cpp | 13 + Coursework/Mortgage.cpp | 1 + Coursework/Mortgage.h | 39 +++ Coursework/Payment.cpp | 1 + Coursework/Payment.h | 31 +++ Coursework/Person.cpp | 1 + Coursework/Person.h | 20 ++ Coursework/Product.cpp | 1 + Coursework/Product.h | 24 ++ Coursework/Simulation.cpp | 1 + Coursework/Simulation.h | 352 ++++++++++++++++++++++++++ Coursework/Transaction.cpp | 1 + Coursework/Transaction.h | 56 ++++ Coursework/WorkingHours.cpp | 1 + Coursework/WorkingHours.h | 22 ++ 54 files changed, 1621 insertions(+) create mode 100644 Coursework.sln create mode 100644 Coursework/Account.cpp create mode 100644 Coursework/Account.h create mode 100644 Coursework/AccountRequisites.cpp create mode 100644 Coursework/AccountRequisites.h create mode 100644 Coursework/Address.cpp create mode 100644 Coursework/Address.h create mode 100644 Coursework/Bank.cpp create mode 100644 Coursework/Bank.h create mode 100644 Coursework/BankBranch.cpp create mode 100644 Coursework/BankBranch.h create mode 100644 Coursework/BankRequisites.cpp create mode 100644 Coursework/BankRequisites.h create mode 100644 Coursework/CarLoan.cpp create mode 100644 Coursework/CarLoan.h create mode 100644 Coursework/Card.cpp create mode 100644 Coursework/Card.h create mode 100644 Coursework/Cash.cpp create mode 100644 Coursework/Cash.h create mode 100644 Coursework/ConsumerLoan.cpp create mode 100644 Coursework/ConsumerLoan.h create mode 100644 Coursework/Coursework.vcxproj create mode 100644 Coursework/Coursework.vcxproj.filters create mode 100644 Coursework/CurrencyExchange.cpp create mode 100644 Coursework/CurrencyExchange.h create mode 100644 Coursework/Customer.cpp create mode 100644 Coursework/Customer.h create mode 100644 Coursework/Deposit.cpp create mode 100644 Coursework/Deposit.h create mode 100644 Coursework/Employee.cpp create mode 100644 Coursework/Employee.h create mode 100644 Coursework/Enums.cpp create mode 100644 Coursework/Enums.h create mode 100644 Coursework/Insurance.cpp create mode 100644 Coursework/Insurance.h create mode 100644 Coursework/Investment.cpp create mode 100644 Coursework/Investment.h create mode 100644 Coursework/Loan.cpp create mode 100644 Coursework/Loan.h create mode 100644 Coursework/Main.cpp create mode 100644 Coursework/Mortgage.cpp create mode 100644 Coursework/Mortgage.h create mode 100644 Coursework/Payment.cpp create mode 100644 Coursework/Payment.h create mode 100644 Coursework/Person.cpp create mode 100644 Coursework/Person.h create mode 100644 Coursework/Product.cpp create mode 100644 Coursework/Product.h create mode 100644 Coursework/Simulation.cpp create mode 100644 Coursework/Simulation.h create mode 100644 Coursework/Transaction.cpp create mode 100644 Coursework/Transaction.h create mode 100644 Coursework/WorkingHours.cpp create mode 100644 Coursework/WorkingHours.h diff --git a/Coursework.sln b/Coursework.sln new file mode 100644 index 0000000..984fa32 --- /dev/null +++ b/Coursework.sln @@ -0,0 +1,31 @@ +п»ї +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.9.34622.214 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Coursework", "Coursework\Coursework.vcxproj", "{823D08D7-C6EC-43F1-B960-910C513CFE62}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {823D08D7-C6EC-43F1-B960-910C513CFE62}.Debug|x64.ActiveCfg = Debug|x64 + {823D08D7-C6EC-43F1-B960-910C513CFE62}.Debug|x64.Build.0 = Debug|x64 + {823D08D7-C6EC-43F1-B960-910C513CFE62}.Debug|x86.ActiveCfg = Debug|Win32 + {823D08D7-C6EC-43F1-B960-910C513CFE62}.Debug|x86.Build.0 = Debug|Win32 + {823D08D7-C6EC-43F1-B960-910C513CFE62}.Release|x64.ActiveCfg = Release|x64 + {823D08D7-C6EC-43F1-B960-910C513CFE62}.Release|x64.Build.0 = Release|x64 + {823D08D7-C6EC-43F1-B960-910C513CFE62}.Release|x86.ActiveCfg = Release|Win32 + {823D08D7-C6EC-43F1-B960-910C513CFE62}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {B12202D9-2A7E-49E3-97B3-BBF511E8B065} + EndGlobalSection +EndGlobal diff --git a/Coursework/Account.cpp b/Coursework/Account.cpp new file mode 100644 index 0000000..e2afcfc --- /dev/null +++ b/Coursework/Account.cpp @@ -0,0 +1 @@ +#include "Account.h" diff --git a/Coursework/Account.h b/Coursework/Account.h new file mode 100644 index 0000000..0cc1e8c --- /dev/null +++ b/Coursework/Account.h @@ -0,0 +1,27 @@ +#pragma once +#include "AccountRequisites.h" +#include "Product.h" + +class Account : public Product +{ +public: + unsigned long long balance = 0; + AccountRequisites accountRequisites; + + Account() : Product("Банковский счёт") {}; + Account( + bool isAvailable, + unsigned long long balance, + AccountRequisites accountRequisites + ) : Product( + "Банковский счёт", + isAvailable + ) { + this->balance = balance; + this->accountRequisites = accountRequisites; + }; + + void withdraw(unsigned long long balance) {}; + void deposit(unsigned long long amount) {}; +}; + diff --git a/Coursework/AccountRequisites.cpp b/Coursework/AccountRequisites.cpp new file mode 100644 index 0000000..d9af23c --- /dev/null +++ b/Coursework/AccountRequisites.cpp @@ -0,0 +1 @@ +#include "AccountRequisites.h" diff --git a/Coursework/AccountRequisites.h b/Coursework/AccountRequisites.h new file mode 100644 index 0000000..cdcc11c --- /dev/null +++ b/Coursework/AccountRequisites.h @@ -0,0 +1,24 @@ +#pragma once +#include +#include "BankRequisites.h" + +class AccountRequisites +{ +public: + std::string owner = ""; + unsigned long long accountNumber = 0; + BankRequisites bankRequisites; + + AccountRequisites() = default; + AccountRequisites( + std::string owner, + unsigned long long accountNumber, + BankRequisites bankRequisites + ) { + this->owner = owner; + this->accountNumber = accountNumber; + this->bankRequisites = bankRequisites; + }; +}; + + diff --git a/Coursework/Address.cpp b/Coursework/Address.cpp new file mode 100644 index 0000000..9c0825c --- /dev/null +++ b/Coursework/Address.cpp @@ -0,0 +1 @@ +#include "Address.h" diff --git a/Coursework/Address.h b/Coursework/Address.h new file mode 100644 index 0000000..13f9133 --- /dev/null +++ b/Coursework/Address.h @@ -0,0 +1,30 @@ +#pragma once +#include + +class Address +{ +public: + std::string country = ""; + std::string state = ""; + std::string city = ""; + unsigned int postalCode = 0; + std::string street = ""; + unsigned int building = 0; + Address() = default; + Address( + std::string country, + std::string state, + std::string city, + unsigned int postalCode, + std::string street, + unsigned int building + ) { + this->country = country; + this->state = state; + this->city = city; + this->postalCode = postalCode; + this->street = street; + this->building = building; + } +}; + diff --git a/Coursework/Bank.cpp b/Coursework/Bank.cpp new file mode 100644 index 0000000..cbddaf4 --- /dev/null +++ b/Coursework/Bank.cpp @@ -0,0 +1 @@ +#include "Bank.h" diff --git a/Coursework/Bank.h b/Coursework/Bank.h new file mode 100644 index 0000000..e5d2ded --- /dev/null +++ b/Coursework/Bank.h @@ -0,0 +1,28 @@ +#pragma once +#include +#include "WorkingHours.h" +#include "BankRequisites.h" + +class Bank +{ +public: + + WorkingHours workingHours; + BankRequisites bankRequisites; + + Bank() = default; + + Bank(WorkingHours workingHours, BankRequisites bankRequisites) { + this->workingHours = workingHours; + this->bankRequisites = bankRequisites; + }; + + bool isWorkingNow() { + unsigned int currentHours = ((time(0) / 3600) % 24) + 4 ; + return ( + currentHours >= workingHours.getFrom() && \ + currentHours < workingHours.getTo()) ? true : false; + }; + +}; + diff --git a/Coursework/BankBranch.cpp b/Coursework/BankBranch.cpp new file mode 100644 index 0000000..688bc10 --- /dev/null +++ b/Coursework/BankBranch.cpp @@ -0,0 +1 @@ +#include "BankBranch.h" diff --git a/Coursework/BankBranch.h b/Coursework/BankBranch.h new file mode 100644 index 0000000..8914d17 --- /dev/null +++ b/Coursework/BankBranch.h @@ -0,0 +1,29 @@ +#pragma once +#include "Bank.h" +#include "Product.h" +#include "Employee.h" +#include + +class BankBranch : public Bank +{ +public: + + std::vector productList = {}; + std::vector employeeList = {}; + + BankBranch() = default; + BankBranch( + WorkingHours workingHours, + BankRequisites bankRequisites + ) : Bank( + workingHours, + bankRequisites + ) { + + } + + void report() { + //report to headquarter + }; +}; + diff --git a/Coursework/BankRequisites.cpp b/Coursework/BankRequisites.cpp new file mode 100644 index 0000000..5880112 --- /dev/null +++ b/Coursework/BankRequisites.cpp @@ -0,0 +1 @@ +#include "BankRequisites.h" diff --git a/Coursework/BankRequisites.h b/Coursework/BankRequisites.h new file mode 100644 index 0000000..2c60183 --- /dev/null +++ b/Coursework/BankRequisites.h @@ -0,0 +1,77 @@ +#pragma once +#include +#include "Address.h" + +class BankRequisites +{ +public: + std::string bankName = ""; + unsigned long long bankBIK = 0; + unsigned long long bankCorrAccount = 0; + unsigned long long bankINN = 0; + unsigned long long bankKPP = 0; + unsigned long long bankOKPO = 0; + unsigned long long bankOGRN = 0; + std::string bankSWIFTcode = ""; + Address addressMain; + Address addressSub; + + BankRequisites() = default; + BankRequisites( + std::string bankName, + unsigned long long bankBIK, + unsigned long long bankCorrAccount, + unsigned long long bankINN, + unsigned long long bankKPP, + unsigned long long bankOKPO, + unsigned long long bankOGRN, + std::string bankSWIFTcode, + Address addressMain, + Address addressSub + ) { + this->bankName = bankName; + this->bankBIK = bankBIK; + this->bankCorrAccount = bankCorrAccount; + this->bankINN = bankINN; + this->bankKPP = bankKPP; + this->bankOKPO = bankOKPO; + this->bankOGRN = bankOGRN; + this->bankSWIFTcode = bankSWIFTcode; + this->addressMain = addressMain; + this->addressSub = addressSub; + }; + //Constructor for bank without branch + BankRequisites( + std::string bankName, + unsigned long long bankBIK, + unsigned long long bankCorrAccount, + unsigned long long bankINN, + unsigned long long bankKPP, + unsigned long long bankOKPO, + unsigned long long bankOGRN, + std::string bankSWIFTcode, + Address addressMain + ) { + this->bankName = bankName; + this->bankBIK = bankBIK; + this->bankCorrAccount = bankCorrAccount; + this->bankINN = bankINN; + this->bankKPP = bankKPP; + this->bankOKPO = bankOKPO; + this->bankOGRN = bankOGRN; + this->bankSWIFTcode = bankSWIFTcode; + this->addressMain = addressMain; + this->addressSub = Address(); + }; + //Constructor for transaction + BankRequisites( + std::string bankName, + unsigned long long bankBIK, + unsigned long long bankCorrAccount + ) { + this->bankName = bankName; + this->bankBIK = bankBIK; + this->bankCorrAccount = bankCorrAccount; + }; +}; + diff --git a/Coursework/CarLoan.cpp b/Coursework/CarLoan.cpp new file mode 100644 index 0000000..0c47026 --- /dev/null +++ b/Coursework/CarLoan.cpp @@ -0,0 +1 @@ +#include "CarLoan.h" diff --git a/Coursework/CarLoan.h b/Coursework/CarLoan.h new file mode 100644 index 0000000..205bda9 --- /dev/null +++ b/Coursework/CarLoan.h @@ -0,0 +1,41 @@ +#pragma once +#include "Loan.h" +#include "Insurance.h" + +class CarLoan : + public Loan +{ +public: + std::string make = ""; + std::string model = ""; + unsigned int year = 0; + Insurance insurance; + CarLoan() : Loan("Автокредит") {}; + CarLoan( + bool isAvailable, + Account account, + unsigned long long amount, + double percent, + unsigned int durationInMonths, + std::string make, + std::string model, + unsigned int year + ) : Loan( + "Автокредит", + isAvailable, + account, + amount, + percent, + durationInMonths + ) { + this->make = make; + this->model = model; + this->year = year; + }; + void applyInsurance( + Insurance insurance + ) { + this->insurance = insurance; + }; +}; + diff --git a/Coursework/Card.cpp b/Coursework/Card.cpp new file mode 100644 index 0000000..e41658e --- /dev/null +++ b/Coursework/Card.cpp @@ -0,0 +1 @@ +#include "Card.h" diff --git a/Coursework/Card.h b/Coursework/Card.h new file mode 100644 index 0000000..3cc3252 --- /dev/null +++ b/Coursework/Card.h @@ -0,0 +1,34 @@ +#pragma once +#include "Product.h" +#include "Account.h" + +class Card : public Product +{ +public: + Account account; + unsigned long long number = 0; + std::string cardHolderName = ""; + unsigned int expirationDate = 0; + unsigned int CVV = 0; + + Card() : Product("Банковская карта") {}; + Card( + bool isAvailable, + Account account, + unsigned long long number, + std::string cardHolderName, + unsigned int expirationDate, + unsigned int CVV + ) : Product( + "Банковская Карта", + isAvailable + ) { + this->account = account; + this->number = number; + this->cardHolderName = cardHolderName; + this->expirationDate = expirationDate; + this->CVV = CVV; + }; + void ban() {}; +}; + diff --git a/Coursework/Cash.cpp b/Coursework/Cash.cpp new file mode 100644 index 0000000..5e2f284 --- /dev/null +++ b/Coursework/Cash.cpp @@ -0,0 +1 @@ +#include "Cash.h" diff --git a/Coursework/Cash.h b/Coursework/Cash.h new file mode 100644 index 0000000..e8c876d --- /dev/null +++ b/Coursework/Cash.h @@ -0,0 +1,27 @@ +#pragma once +#include "Transaction.h" +class Cash : + public Transaction +{ +public: + Cash() : Transaction("Операции с наличными") {}; + + Cash( + bool isAvailable, + AccountRequisites payerRequisites, + AccountRequisites recipientRequisites, + unsigned long long amount, + unsigned int date + ) : Transaction( + "Операции с наличными", + isAvailable, + payerRequisites, + recipientRequisites, + amount, + date + ) {}; + + void cashIn(unsigned long long amount) {}; + void cashOut(unsigned long long amount) {}; +}; + diff --git a/Coursework/ConsumerLoan.cpp b/Coursework/ConsumerLoan.cpp new file mode 100644 index 0000000..be22a39 --- /dev/null +++ b/Coursework/ConsumerLoan.cpp @@ -0,0 +1 @@ +#include "ConsumerLoan.h" diff --git a/Coursework/ConsumerLoan.h b/Coursework/ConsumerLoan.h new file mode 100644 index 0000000..3fa0cbc --- /dev/null +++ b/Coursework/ConsumerLoan.h @@ -0,0 +1,29 @@ +#pragma once +#include "Loan.h" + +class ConsumerLoan : + public Loan +{ +public: + std::string purpose = ""; + ConsumerLoan() : Loan("Потребительский кредит") {}; + ConsumerLoan( + bool isAvailable, + Account account, + unsigned long long amount, + double percent, + unsigned int durationInMonths, + std::string purpose + ) : Loan( + "Потребительский кредит", + isAvailable, + account, + amount, + percent, + durationInMonths + ) { + this->purpose = purpose; + }; + void increase(unsigned long long amount) {}; +}; + diff --git a/Coursework/Coursework.vcxproj b/Coursework/Coursework.vcxproj new file mode 100644 index 0000000..5deb9b0 --- /dev/null +++ b/Coursework/Coursework.vcxproj @@ -0,0 +1,187 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 17.0 + Win32Proj + {823d08d7-c6ec-43f1-b960-910c513cfe62} + Coursework + 10.0 + + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Coursework/Coursework.vcxproj.filters b/Coursework/Coursework.vcxproj.filters new file mode 100644 index 0000000..e1f221b --- /dev/null +++ b/Coursework/Coursework.vcxproj.filters @@ -0,0 +1,174 @@ +п»ї + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Resource Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + \ No newline at end of file diff --git a/Coursework/CurrencyExchange.cpp b/Coursework/CurrencyExchange.cpp new file mode 100644 index 0000000..1f3af6b --- /dev/null +++ b/Coursework/CurrencyExchange.cpp @@ -0,0 +1 @@ +#include "CurrencyExchange.h" diff --git a/Coursework/CurrencyExchange.h b/Coursework/CurrencyExchange.h new file mode 100644 index 0000000..8c430e5 --- /dev/null +++ b/Coursework/CurrencyExchange.h @@ -0,0 +1,39 @@ +#pragma once +#include "Transaction.h" +#include "Enums.h" +#include + +class CurrencyExchange : + public Transaction +{ +public: + Currency currencyFrom; + Currency currencyTo; + + CurrencyExchange() :Transaction("Обмен валюты") {}; + CurrencyExchange( + bool isAvailable, + AccountRequisites payerRequisites, + AccountRequisites recipientRequisites, + unsigned long long amount, + unsigned int date, + Currency currencyFrom, + Currency currencyTo + ) : Transaction( + "Обмен валюты", + isAvailable, + payerRequisites, + recipientRequisites, + amount, + date + ) { + this->currencyFrom = currencyFrom; + this->currencyTo = currencyTo; + }; + std::string executeTest() { + return (this->currencyTo == USD) ? \ + "Операция отклонена, нет валюты USD\n": \ + "Операция исполнена\n"; + }; +}; + diff --git a/Coursework/Customer.cpp b/Coursework/Customer.cpp new file mode 100644 index 0000000..90380a5 --- /dev/null +++ b/Coursework/Customer.cpp @@ -0,0 +1 @@ +#include "Customer.h" diff --git a/Coursework/Customer.h b/Coursework/Customer.h new file mode 100644 index 0000000..f833539 --- /dev/null +++ b/Coursework/Customer.h @@ -0,0 +1,24 @@ +#pragma once +#include "Person.h" +#include "Enums.h" +#include +#include + +class Customer : public Person +{ +public: + std::vector needList; + + Customer() = default; + Customer(std::string name, std::vector needList) : Person(name) { + this->needList = needList; + }; + + std::string askForHelp(Need need) { + return needConverter(need); + }; + std::string askForHelp(std::string verboseNeed) { + return verboseNeed; + }; +}; + diff --git a/Coursework/Deposit.cpp b/Coursework/Deposit.cpp new file mode 100644 index 0000000..ae8f67d --- /dev/null +++ b/Coursework/Deposit.cpp @@ -0,0 +1 @@ +#include "Deposit.h" diff --git a/Coursework/Deposit.h b/Coursework/Deposit.h new file mode 100644 index 0000000..74944f0 --- /dev/null +++ b/Coursework/Deposit.h @@ -0,0 +1,24 @@ +#pragma once +#include "Product.h" +#include "Account.h" + +class Deposit : public Product +{ +public: + Account account; + unsigned long long amount = 0; + + Deposit() : Product("Банковский вклад") {}; + Deposit( + bool isAvailable, + Account account, + unsigned long long amount + ) : Product( + "Банковский вклад", + isAvailable + ) { + this->account = account; + this->amount = amount; + }; +}; + diff --git a/Coursework/Employee.cpp b/Coursework/Employee.cpp new file mode 100644 index 0000000..b0c2c2c --- /dev/null +++ b/Coursework/Employee.cpp @@ -0,0 +1 @@ +#include "Employee.h" diff --git a/Coursework/Employee.h b/Coursework/Employee.h new file mode 100644 index 0000000..a405f42 --- /dev/null +++ b/Coursework/Employee.h @@ -0,0 +1,44 @@ +#pragma once +#include "Enums.h" +#include "Person.h" +#include +#include +#include +#include "Product.h" +#include "Account.h" +#include "Customer.h" + +class Employee : public Person +{ +public: + JobTitle jobTitle; + + Employee() = default; + Employee(std::string name, JobTitle jobTitle) : Person(name) { + this->jobTitle = jobTitle; + }; + + std::string auth(Person person) { + return (this->name + " проводит идентификацию " +\ + person.name + "\n"); + }; + unsigned long long getBalanceRemainder(Account account) { + return account.balance; + }; + std::string offerHelp(Person person, std::vector productList) { + std::string productListToString = ""; + for (Product product: productList) { + productListToString += product.productName + "\n"; + }; + return (this->name + " предлагает " + person.name + \ + ", следующие продукты:\n" + productListToString); + }; + std::string denyService(Person person) { + return (person.name + " отказано в обслуживании\n"); + }; + std::string executeTest(Customer customer) { + int cnt = std::count(customer.needList.begin(), customer.needList.end(), UnknownNeed); + return ((cnt && customer.needList.size() != 0) ? denyService(customer) : "Добро пожаловать\n"); + }; +}; + diff --git a/Coursework/Enums.cpp b/Coursework/Enums.cpp new file mode 100644 index 0000000..84f4b01 --- /dev/null +++ b/Coursework/Enums.cpp @@ -0,0 +1 @@ +#include "Enums.h" diff --git a/Coursework/Enums.h b/Coursework/Enums.h new file mode 100644 index 0000000..cd9a297 --- /dev/null +++ b/Coursework/Enums.h @@ -0,0 +1,88 @@ +#pragma once +enum JobTitle { + Receptionist, + BankTeller, + Cashier, + Security, + Manager, +}; + +inline const char* jobTitleConverter(JobTitle jobTitle) +{ + switch (jobTitle) + { + case Receptionist: return "Ресепшионист"; + case BankTeller: return "Операционист"; + case Cashier: return "Кассир"; + case Security: return "Охранник"; + case Manager: return "Управляющий"; + default: return "Безработный"; + } +} + +enum Need { + GetLoan, + GetCard, + OpenDeposit, + Invest, + MakePayment, + MakeTransfer, + ExchangeCurrency, + UnknownNeed +}; +inline const char* needConverter(Need need) +{ + switch (need) + { + case GetLoan: return "Занять деньги"; + case GetCard: return "Получить карту"; + case OpenDeposit: return "Открыть вклад"; + case Invest: return "Инвестировать"; + case MakePayment: return "Оплатить"; + case MakeTransfer: return "Перевести"; + case ExchangeCurrency: return "Обменять"; + case UnknownNeed: return "Неизвестно"; + default: return "Улыбаться"; + } +} + +enum PropertyType { + Land, + House, + Townhose, + Appartment, + UnknownPropertyType +}; + +inline const char* propertyTypeConverter(PropertyType propertyType) +{ + switch (propertyType) + { + case Land: return "Земельный участок"; + case House: return "Дом"; + case Townhose: return "Таунхаус"; + case Appartment: return "Квартира"; + case UnknownPropertyType: return "Неизвестный тип недвижимости"; + default: return "Воздух"; + } +} + +enum Currency +{ + RUB, + USD, + EUR, + BGN +}; + +inline const char* currencyConverter(Currency currency) +{ + switch (currency) + { + case RUB: return "Российский рубль"; + case USD: return "Американский доллар"; + case EUR: return "Евро"; + case BGN: return "Болгарский лев"; + default: return "Деньги"; + } +} diff --git a/Coursework/Insurance.cpp b/Coursework/Insurance.cpp new file mode 100644 index 0000000..0d74439 --- /dev/null +++ b/Coursework/Insurance.cpp @@ -0,0 +1 @@ +#include "Insurance.h" diff --git a/Coursework/Insurance.h b/Coursework/Insurance.h new file mode 100644 index 0000000..40a5cf4 --- /dev/null +++ b/Coursework/Insurance.h @@ -0,0 +1,18 @@ +#pragma once +class Insurance +{ +public: + unsigned long long amount = 0; + unsigned int durationInMonths = 0; + Insurance() = default; + Insurance( + unsigned long long amount, + unsigned int durationInMonths + ) { + this->amount = amount; + this->durationInMonths = durationInMonths; + }; + void open() {}; + void close() {}; +}; + diff --git a/Coursework/Investment.cpp b/Coursework/Investment.cpp new file mode 100644 index 0000000..2e7d74e --- /dev/null +++ b/Coursework/Investment.cpp @@ -0,0 +1 @@ +#include "Investment.h" diff --git a/Coursework/Investment.h b/Coursework/Investment.h new file mode 100644 index 0000000..96b8de6 --- /dev/null +++ b/Coursework/Investment.h @@ -0,0 +1,30 @@ +#pragma once +#include "Account.h" +#include "Product.h" + +class Investment : public Product +{ +public: + unsigned long long amount = 0; + double percent = 0; + Account account; + + Investment() : Product("Инвестиционный продукт") {}; + Investment( + bool isAvailable, + unsigned long long amount, + double percent, + Account account + ) : Product( + "Инвестиционный продукт", + isAvailable + ) { + this->amount = amount; + this->percent = percent; + this->account = account; + }; + void rebalance() {}; + void invest(unsigned long long amount) {}; + void withdraw(unsigned long long amount) {}; +}; + diff --git a/Coursework/Loan.cpp b/Coursework/Loan.cpp new file mode 100644 index 0000000..d571432 --- /dev/null +++ b/Coursework/Loan.cpp @@ -0,0 +1 @@ +#include "Loan.h" diff --git a/Coursework/Loan.h b/Coursework/Loan.h new file mode 100644 index 0000000..b6b58b8 --- /dev/null +++ b/Coursework/Loan.h @@ -0,0 +1,34 @@ +#pragma once +#include "Account.h" + +class Loan : public Product +{ +public: + Account account; + unsigned long long amount = 0; + double percent = 0; + unsigned int durationInMonths = 0; + + Loan(std::string name) : Product(name) {}; + Loan( + std::string name, + bool isAvailable, + Account account, + unsigned long long amount, + double percent, + unsigned int durationInMonths + ) : Product( + name, + isAvailable + ) { + this->account = account; + this->amount = amount; + this->percent = percent; + this->durationInMonths = durationInMonths; + }; + + void refinancing() {}; + void payOff() {}; + void bankrupt() {}; +}; + diff --git a/Coursework/Main.cpp b/Coursework/Main.cpp new file mode 100644 index 0000000..a65712c --- /dev/null +++ b/Coursework/Main.cpp @@ -0,0 +1,13 @@ +#include +#include "Simulation.h" + +int main() { + setlocale(LC_ALL, "ru"); + Simulation simulation; + simulation.execute(); + + simulation.executeTest(); + + system("pause"); + return 0; +}; \ No newline at end of file diff --git a/Coursework/Mortgage.cpp b/Coursework/Mortgage.cpp new file mode 100644 index 0000000..db30d18 --- /dev/null +++ b/Coursework/Mortgage.cpp @@ -0,0 +1 @@ +#include "Mortgage.h" diff --git a/Coursework/Mortgage.h b/Coursework/Mortgage.h new file mode 100644 index 0000000..b2ae6c6 --- /dev/null +++ b/Coursework/Mortgage.h @@ -0,0 +1,39 @@ +#pragma once +#include "Enums.h" +#include "Loan.h" + +class Mortgage : public Loan +{ +public: + PropertyType property = PropertyType::Appartment; + double discount = 0; + Mortgage() : Loan("Ипотека") {}; + Mortgage( + bool isAvailable, + Account account, + unsigned long long amount, + double percent, + unsigned int durationInMonths, + PropertyType property + ) : Loan( + "Ипотека", + isAvailable, + account, + amount, + percent, + durationInMonths + ) { + this->property = property; + }; + void applyDiscount( + double discount + ) { + this->discount = discount; + }; + std::string executeTest() { + return (this->property == UnknownPropertyType) ? \ + "Отказано в ипотеке, не поддерживаемый тип недвижимости\n" : \ + "Ипотека одобрена\n"; + }; +}; + diff --git a/Coursework/Payment.cpp b/Coursework/Payment.cpp new file mode 100644 index 0000000..a9f0982 --- /dev/null +++ b/Coursework/Payment.cpp @@ -0,0 +1 @@ +#include "Payment.h" diff --git a/Coursework/Payment.h b/Coursework/Payment.h new file mode 100644 index 0000000..389c81c --- /dev/null +++ b/Coursework/Payment.h @@ -0,0 +1,31 @@ +#pragma once +#include "Transaction.h" + +class Payment : + public Transaction +{ +public: + std::string purpose = ""; + unsigned int MCCCode = 0; + Payment() : Transaction("Платёж") {}; + Payment( + bool isAvailable, + AccountRequisites payerRequisites, + AccountRequisites recipientRequisites, + unsigned long long amount, + unsigned int date, + std::string purpose, + unsigned int MCCCode + ) : Transaction( + "Платёж", + isAvailable, + payerRequisites, + recipientRequisites, + amount, + date + ) { + this->purpose = purpose; + this->MCCCode = MCCCode; + }; +}; + diff --git a/Coursework/Person.cpp b/Coursework/Person.cpp new file mode 100644 index 0000000..6beda4d --- /dev/null +++ b/Coursework/Person.cpp @@ -0,0 +1 @@ +#include "Person.h" diff --git a/Coursework/Person.h b/Coursework/Person.h new file mode 100644 index 0000000..edcd67a --- /dev/null +++ b/Coursework/Person.h @@ -0,0 +1,20 @@ +#pragma once +#include + +class Person +{ +public: + std::string name = ""; + Person() = default; + Person(std::string name) { + this->name = name; + }; + std::string communicate(Person person) { + return (this->name + " общается с " + person.name + "\n"); + }; + + std::string greet(Person person) { + return (this->name + " приветствует " + person.name + "\n"); + }; +}; + diff --git a/Coursework/Product.cpp b/Coursework/Product.cpp new file mode 100644 index 0000000..3f4dc4b --- /dev/null +++ b/Coursework/Product.cpp @@ -0,0 +1 @@ +#include "Product.h" diff --git a/Coursework/Product.h b/Coursework/Product.h new file mode 100644 index 0000000..a1fc2c1 --- /dev/null +++ b/Coursework/Product.h @@ -0,0 +1,24 @@ +#pragma once +#include + +class Product +{ +public: + std::string productName = ""; + bool isAvailable = true; + Product() = default; + Product(std::string name) { + this->productName = name; + }; + Product(std::string name, bool isAvailable) { + this->productName = name; + this->isAvailable = isAvailable; + } + void open() { + this->isAvailable = true; + } + void close() { + this->isAvailable = false; + } +}; + diff --git a/Coursework/Simulation.cpp b/Coursework/Simulation.cpp new file mode 100644 index 0000000..58c08f9 --- /dev/null +++ b/Coursework/Simulation.cpp @@ -0,0 +1 @@ +#include "Simulation.h" diff --git a/Coursework/Simulation.h b/Coursework/Simulation.h new file mode 100644 index 0000000..af5c0f7 --- /dev/null +++ b/Coursework/Simulation.h @@ -0,0 +1,352 @@ +#pragma once +#include +#include +#include +#include +#include +#include "BankBranch.h" +#include "Employee.h" +#include "Enums.h" +#include "Customer.h" +#include "Account.h" +#include "AccountRequisites.h" +#include "ConsumerLoan.h" +#include "CarLoan.h" +#include "Mortgage.h" +#include "Card.h" +#include "Cash.h" +#include "Transaction.h" +#include "Payment.h" +#include "CurrencyExchange.h" +#include "Deposit.h" +#include "Investment.h" + +class Simulation +{ +private: + + WorkingHours workingHours = WorkingHours( + 9, + 17 + ); + Address addressHeadquarter = Address( + "Россия", + "Московская область", + "Москва", + 101000, + "улица Чайная", + 1 + ); + Address addressBranch = Address( + "Россия", + "Самарская область", + "Тольятти", + 445030, + "бульвар Золотистый", + 1 + ); + Address foreignBankAddress = Address( + "Болгария", + "Варненская область", + "Варна", + 9000, + "бульвар Сливница", + 43 + ); + BankRequisites bankRequisites = BankRequisites( + "Банк Золотая Чаша", + 123456789, + 10101810000000000000, + 121212121212, + 565656565, + 32323232, + 1122334455667, + "GLDRRUMM", + addressHeadquarter, + addressBranch + ); + BankRequisites foreignBankRequisites = BankRequisites( + "Банк Черен Пепер", + 1234999989, + 10221421700000000000, + 121233321212, + 565659995, + 32999232, + 1122334495667, + "CHPRRUMM", + foreignBankAddress + ); + + BankBranch bankBranch = BankBranch( + workingHours, + bankRequisites + ); + + Employee receptionist = Employee( + "Алла Пугачева", + Receptionist + ); + Employee bankTeller = Employee( + "Верка Сердючка", + BankTeller + ); + Employee cashier = Employee( + "Ирина Аллегрова", + Cashier + ); + Employee security = Employee( + "Стас Михайлов", + Security + ); + Employee manager = Employee( + "Николай Басков", + Manager + ); + Customer customer = Customer( + "Филипп Киркоров", + { + GetLoan, + GetCard, + MakePayment, + MakeTransfer, + ExchangeCurrency + } + ); + AccountRequisites accountRequisites = AccountRequisites( + customer.name, + 121212121212123, + bankRequisites + ); + AccountRequisites recipientRequisites = AccountRequisites( + "ООО Живи Цветя", + 32323232323233, + foreignBankRequisites + ); + AccountRequisites foreignRequisites = AccountRequisites( + customer.name, + 32323232323233, + foreignBankRequisites + ); + Account account = Account( + true, + 0, + accountRequisites + ); + ConsumerLoan consumerLoan = ConsumerLoan( + true, + account, + 1000000, + 6.9, + 420, + "Миллион Алых Роз" + ); + Card card = Card( + true, + account, + 123123123123, + customer.name, + 3000, + 123 + ); + Transaction transaction = Transaction( + true, + accountRequisites, + foreignRequisites, + 500000, + time(0) + ); + Payment payment = Payment( + true, + accountRequisites, + recipientRequisites, + 300000, + time(0), + "Миллион Алых Роз", + 6969 + ); + CurrencyExchange currencyExchange = CurrencyExchange( + true, + accountRequisites, + accountRequisites, + 100000, + time(0), + Currency::RUB, + Currency::BGN + ); + Deposit deposit = Deposit( + true, + account, + 50000 + ); + Investment investment = Investment( + true, + 50000, + 9, + account + ); + + void init() { + bankBranch.productList.push_back(Account()); + bankBranch.productList.push_back(Card()); + bankBranch.productList.push_back(Mortgage()); + bankBranch.productList.push_back(ConsumerLoan()); + bankBranch.productList.push_back(CarLoan()); + bankBranch.productList.push_back(Deposit()); + bankBranch.productList.push_back(Investment()); + bankBranch.productList.push_back(Transaction()); + bankBranch.productList.push_back(Payment()); + bankBranch.productList.push_back(Cash()); + bankBranch.productList.push_back(CurrencyExchange()); + + bankBranch.employeeList.push_back(receptionist); + bankBranch.employeeList.push_back(security); + bankBranch.employeeList.push_back(bankTeller); + bankBranch.employeeList.push_back(cashier); + bankBranch.employeeList.push_back(manager); + + }; + +public: + Simulation() = default; + + void executeTest() { + init(); + + std::cout << "============testcase START=============\n"; + std::cout << "============testcase1=============\n"; + std::cout << "\nРежим работы: с " << bankBranch.workingHours.getFrom() + << " до " << bankBranch.workingHours.getTo() << "\n"; + std::cout << "В данное время банк " << (bankBranch.isWorkingNow() ? \ + "работает.\n\n" : "не работает.\n\n"); + + std::cout << "============testcase2=============\n"; + Customer customerWithUnknownNeed = Customer( + "Григорий", + {UnknownNeed} + ); + std::cout << receptionist.executeTest(customerWithUnknownNeed); + + std::cout << "============testcase3=============\n"; + CurrencyExchange denyCurrencyExchange = CurrencyExchange( + true, + accountRequisites, + accountRequisites, + 100, + time(0), + RUB, + USD + ); + std::cout << denyCurrencyExchange.executeTest(); + + std::cout << "============testcase4=============\n"; + Mortgage denyMortgage = Mortgage( + true, + account, + 1000000, + 10, + 120, + UnknownPropertyType + ); + std::cout << denyMortgage.executeTest(); + + std::cout << "============testcase5=============\n"; + Account noSufficientFundAccount = Account( + true, + 10, + accountRequisites + ); + Transaction noSufficientFundTransaction = Transaction( + true, + accountRequisites, + foreignRequisites, + 500000, + time(0) + ); + std::cout << noSufficientFundTransaction.executeTest(noSufficientFundAccount); + std::cout << "============testcase END=============\n"; + }; + + void execute() { + init(); + std::cout << "============1=============\n"; + std::cout << "Филиал " << bankBranch.bankRequisites.bankName << "\n"; + std::cout << "Располагается по адресу: Город " << + bankBranch.bankRequisites.addressSub.city << + ", " << bankBranch.bankRequisites.addressSub.street << + ", дом " << bankBranch.bankRequisites.addressSub.building << "\n"; + + std::cout << "\nПредлагает следующие продукты и услуги:\n"; + for (Product product : bankBranch.productList) + { + std::cout << product.productName << "\n"; + }; + std::cout << "\nРежим работы: с " << bankBranch.workingHours.getFrom() << " до " + << bankBranch.workingHours.getTo() << "\n"; + std::cout << "В данное время банк " << (bankBranch.isWorkingNow() ? "работает.\n\n" : "не работает.\n\n"); + + std::cout << "Персонал филиала банка: \n"; + for (Employee employee: bankBranch.employeeList) { + std::cout << employee.name << " в должности " << jobTitleConverter(employee.jobTitle) << "\n"; + }; + + std::cout << "\n============2=============\n"; + std::cout << "Клиент и ресепшионист приветствуют друг друга: \n"; + std::cout << customer.greet(receptionist); + std::cout << receptionist.greet(customer); + std::cout << "\n============3=============\n"; + std::cout << "Клиент озвучивает причину визита: \n"; + std::cout << customer.askForHelp(GetLoan); + std::cout << "\n============4=============\n"; + std::cout << "Ресепшионист делегирует клиента операционисту: \n"; + std::cout << receptionist.communicate(bankTeller); + std::cout << "\n============5=============\n"; + std::cout << "Операционист озвучивает банковские продукты с заёмными средствами : \n"; + std::cout << bankTeller.offerHelp(customer, {Mortgage(),CarLoan(),ConsumerLoan()}); + std::cout << "\n============6=============\n"; + std::cout << "Клиент озвучивает цель кредита: \n"; + std::cout << customer.askForHelp("Миллион алых роз\n"); + std::cout << "\n============7=============\n"; + std::cout << "Операционист проводит идентификацию клиента: \n"; + std::cout << bankTeller.auth(customer); + std::cout << "\n============8=============\n"; + std::cout << "Операционист заводит банковские продукты: \n"; + std::cout << "Счет с номером: \n"; + std::cout << account.accountRequisites.accountNumber << "\n"; + std::cout << "Потребительский кредит на сумму: \n"; + std::cout << consumerLoan.amount << "\n"; + account.balance += consumerLoan.amount; + std::cout << "Банковская карта с номером: \n"; + std::cout << card.number << "\n"; + std::cout << "\n============9=============\n"; + std::cout << "Клиент в кассе: \n"; + std::cout << "1. Совершает платеж на сумму: \n"; + account.balance -= payment.amount; + std::cout << payment.amount << "\n"; + std::cout << "в пользу: \n"; + std::cout << payment.recipientRequisites.owner << "\n"; + std::cout << "2. Совершает перевод на сумму: \n"; + account.balance -= transaction.amount; + std::cout << transaction.amount << "\n"; + std::cout << "на свой счет в болгарский банк: \n"; + std::cout << transaction.recipientRequisites.bankRequisites.bankName << "\n"; + std::cout << "3. Приобретает валюту: \n"; + account.balance -= currencyExchange.amount; + std::cout << currencyConverter(currencyExchange.currencyTo) << "\n"; + std::cout << "на сумму: \n"; + std::cout << currencyExchange.amount << "\n"; + std::cout << "На счету клиента остается заёмных средств в размере: \n"; + std::cout << cashier.getBalanceRemainder(account) << "\n"; + std::cout << "\n============10=============\n"; + std::cout << "Управляющий банка предлагает вложить средства: \n"; + std::cout << manager.offerHelp(customer, {Deposit(), Investment()}) << "\n"; + std::cout << "Открывается вклад на сумму: \n"; + std::cout << deposit.amount << "\n"; + account.balance -= deposit.amount; + std::cout << "Открывается инвестиционный продукт на сумму: \n"; + std::cout << investment.amount << "\n"; + account.balance -= investment.amount; + std::cout << "\n============11=============\n"; + std::cout << "Клиент покидая филиал банка, слышит вслед: \n"; + std::cout << receptionist.communicate(customer) << "\n"; + } +}; diff --git a/Coursework/Transaction.cpp b/Coursework/Transaction.cpp new file mode 100644 index 0000000..06a05ec --- /dev/null +++ b/Coursework/Transaction.cpp @@ -0,0 +1 @@ +#include "Transaction.h" diff --git a/Coursework/Transaction.h b/Coursework/Transaction.h new file mode 100644 index 0000000..4ad1517 --- /dev/null +++ b/Coursework/Transaction.h @@ -0,0 +1,56 @@ +#pragma once +#include "Product.h" +#include "AccountRequisites.h" +#include +#include "Account.h" + +class Transaction : public Product +{ +public: + AccountRequisites payerRequisites; + AccountRequisites recipientRequisites; + unsigned long long amount = 0; + unsigned int date = 0; + + Transaction() : Product("Денежные переводы") {}; + Transaction(std::string name): Product (name) {}; + Transaction( + std::string name, + bool isAvailable, + AccountRequisites payerRequisites, + AccountRequisites recipientRequisites, + unsigned long long amount, + unsigned int date + ) : Product( + name, + isAvailable + ) { + this->payerRequisites = payerRequisites; + this->recipientRequisites = recipientRequisites; + this->amount = amount; + this->date = date; + }; + Transaction( + bool isAvailable, + AccountRequisites payerRequisites, + AccountRequisites recipientRequisites, + unsigned long long amount, + unsigned int date + ) : Product( + "Денежные переводы", + isAvailable + ) { + this->payerRequisites = payerRequisites; + this->recipientRequisites = recipientRequisites; + this->amount = amount; + this->date = date; + }; + void execute() {}; + void cancel() {}; + std::string executeTest(Account account) { + return ((account.balance < this->amount) ? \ + "Операция отклонена, недостаточно средств\n" : \ + "Исполнено\n"); + }; +}; + diff --git a/Coursework/WorkingHours.cpp b/Coursework/WorkingHours.cpp new file mode 100644 index 0000000..1feebc6 --- /dev/null +++ b/Coursework/WorkingHours.cpp @@ -0,0 +1 @@ +#include "WorkingHours.h" diff --git a/Coursework/WorkingHours.h b/Coursework/WorkingHours.h new file mode 100644 index 0000000..3dccfb5 --- /dev/null +++ b/Coursework/WorkingHours.h @@ -0,0 +1,22 @@ +#pragma once +#include + +class WorkingHours +{ +private: + unsigned int from = 0; + unsigned int to = 0; +public: + WorkingHours() = default; + WorkingHours(unsigned int from, unsigned int to) { + this->from = from; + this->to = to; + }; + unsigned int getFrom() { + return this->from; + }; + unsigned int getTo() { + return this->to; + }; +}; +