Created
July 5, 2016 19:50
-
-
Save Soulstorm50/047799df7897a82785aa5373c7618077 to your computer and use it in GitHub Desktop.
Bank
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include"Bank.h" | |
using namespace std; | |
uint Bank::mainBall = 0; | |
Bank::Bank() | |
{ | |
uint fillBall = 0; | |
ushort sizeFil = 0; | |
uint sizeDep = 0; | |
uint sizeCred = 0; | |
uint *deposit = nullptr; | |
uint*credit = nullptr; | |
uint*creditNum = nullptr; | |
uint *filials = nullptr; | |
ushort persent = 0; | |
} | |
Bank::Bank(uint filBall, ushort persent) | |
{ | |
SetFilBall(filBall); | |
SetPersent(persent); | |
} | |
Bank::~Bank() | |
{ | |
delete[]deposit; | |
delete[]credit; | |
delete[]creditNum; | |
delete[]filials; | |
}; | |
uint Bank::GetFilBall()const | |
{ | |
return filBall; | |
} | |
uint Bank::GetMainBall() | |
{ | |
return Bank::mainBall; | |
} | |
void Bank::SetFilBall(uint filBall) | |
{ | |
if (filBall>0) | |
this->filBall = filBall; | |
AddNewFil(this->filBall); | |
SetMainBall(); | |
} | |
void Bank::SetMainBall() | |
{ | |
for (int i = 0; i < sizeFil; i++) | |
Bank::mainBall += filials[i]; | |
} | |
void Bank::SetPersent(ushort persent) | |
{ | |
if (persent>0) | |
this->persent = persent; | |
} | |
void Bank::AddNewFil(uint ball) | |
{ | |
uint*temp = new uint[sizeFil + 1]; | |
for (uint i = 0; i < sizeFil; i++) | |
temp[i] = filials[i]; | |
temp[sizeFil] = ball; | |
delete[]filials; | |
filials = temp; | |
sizeFil++; | |
} | |
void Bank::FormDeposit(uint dep) | |
{ | |
if (dep>0) | |
Bank::mainBall += dep; | |
uint*temp = new uint[sizeDep + 1]; | |
for (uint i = 0; i < sizeDep; i++) | |
temp[i] = deposit[i]; | |
temp[sizeDep] = dep; | |
delete[]deposit; | |
deposit = temp; | |
sizeDep++; | |
} | |
double Bank::FormCredit(double cred) | |
{ | |
if (cred>0) | |
Bank::mainBall -= cred; | |
uint*temp = new uint[sizeCred + 1]; | |
uint*tempNum = new uint[sizeCred + 1]; | |
for (uint i = 0; i < sizeCred; i++) | |
{ | |
tempNum[i] = creditNum[i]; | |
temp[i] = credit[i]; | |
} | |
tempNum[sizeCred] = cred; | |
temp[sizeCred] = cred + ((cred / 100)*persent); | |
delete[]credit; | |
delete[]creditNum; | |
creditNum = tempNum; | |
credit = temp; | |
sizeCred++; | |
return cred; | |
} | |
double Bank::issueDeposit(double dep) | |
{ | |
double persents = 0; | |
for (uint i = 0; i < sizeDep; i++) | |
{ | |
if (deposit[i] == dep) | |
{ | |
persents = (((dep / 100)*persent) + dep); | |
Bank::mainBall -= persents; | |
uint*temp = new uint[sizeDep - 1]; | |
for (uint j = i; j < sizeDep; j++) | |
temp[j] = deposit[j + 1]; | |
delete[]deposit; | |
deposit = temp; | |
sizeDep--; | |
return persents; | |
} | |
else continue; | |
} | |
return persents; | |
} | |
uint Bank::issueCredit(double cred, double value) | |
{ | |
int rest = 0; | |
for (uint i = 0; i < sizeCred; i++) | |
{ | |
if (creditNum[i] == cred) | |
{ | |
if (value < credit[i]) | |
{ | |
Bank::mainBall += value; | |
credit[i] -= value; | |
} | |
else | |
{ | |
Bank::mainBall += credit[i]; | |
rest = value - credit[i]; | |
credit[i] = 0; | |
uint*temp = new uint[sizeCred - 1]; | |
uint*tempNum = new uint[sizeCred - 1]; | |
for (uint j = i; i < sizeCred; i++) | |
{ | |
temp[j] = credit[j + 1]; | |
tempNum[j] = creditNum[j + 1]; | |
} | |
delete[]creditNum; | |
delete[]credit; | |
credit = temp; | |
creditNum = tempNum; | |
sizeCred--; | |
} | |
} | |
else | |
cout << "not found this credit" << endl; | |
} | |
return rest; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include<iostream> | |
typedef unsigned int uint; | |
typedef unsigned short ushort; | |
class Bank | |
{ | |
uint filBall; | |
ushort sizeFil; | |
uint sizeDep; | |
uint sizeCred; | |
uint *filials; | |
uint *deposit; | |
uint*credit; | |
uint*creditNum; | |
ushort persent; | |
void SetMainBall(); | |
void AddNewFil(uint ball); | |
void SetSizeFill(); | |
static uint mainBall; | |
public: | |
Bank(); | |
Bank(uint fillBall, ushort persent); | |
uint GetFilBall()const; | |
static uint GetMainBall(); | |
void SetFilBall(uint fillBall); | |
void FormDeposit(uint dep); | |
double FormCredit(double cred); | |
double issueDeposit(double dep); | |
uint issueCredit(double cred, double value); | |
void payDepozTax(uint rate); | |
void SetPersent(ushort persent); | |
~Bank(); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment