Digital bank for business game in c++

Pv

 


 This program is a digital bank system for business game. With this program you can do all transactions of business game digitally. This is a CLI program. you can add starting money, players and do all money transactions on your pc. 

To use this bot - 
s-1  -> Enter starting money.
s-2  -> Enter total number of players.
s-3  -> Enter name and id of all the players.
s-4  ->  After filling all the details you can view all account detail or you can do transaction.
s-5  -> In transaction, you can transfer money from one player to another, transfer money from one player to all other players, transfer from all players to one player, give money to one player, take money from one player.

Created by - Pv slayer.

Source code - 
 
#include <iostream>
using namespace std;
class digitalbank
{
string playername;
string playerid;
double totalmoney;

public:
digitalbank()
{
cout << "player added." << endl;
}

double startingmoneyset(double startingmoney)
{
totalmoney = startingmoney;
}
void detail_taker(int _1counting)
{
cout << "Enter " << _1counting << " player name : ";
cin.ignore();
getline(cin, playername);
cout << endl;
cout << "Enter player id : ";
getline(cin, playerid);
cout << endl;
}
void showdetail()
{
cout << endl;
cout << " Id- " << playerid << " Name - " << playername << endl;
cout << " Total money - " << totalmoney << endl;
cout << " ___________________________________________" << endl;
}
double minusmoney(double varminus)
{
double tempminus;
totalmoney = totalmoney - varminus;
}
double addmoney(double varadd)
{
double tempadd;
totalmoney = totalmoney + varadd;
}
};
int main()
{
int totalplayers;
int counting = 1;
double startingmoney;
int taskchooserkey;
int transactionkey;
double transferamount;
int atpid, atpid_1;
cout << "Enter starting money : ";
cin >> startingmoney;
for (int i = 0; i < 150; i++)
{
cout << "Enter total players (1,2,3,4,5,6): ";
cin >> totalplayers;
if (totalplayers <= 6)
{
break;
}

}
digitalbank player[totalplayers];
cout << endl;
for (int j = 0; j < totalplayers; j++)
{
player[j].detail_taker(counting);
counting++;
}
for (int hj = 0; hj < totalplayers; hj++)
{
player[hj].startingmoneyset(startingmoney);
}
system("clear");
taskchooser:
cout<<"By - Pv slayer"<<endl;
cout << "Choose task from below : " << endl;
cout << "1. transaction " << endl
<< "2. account info" << endl;
cout << "Please enter key - ";
cin >> taskchooserkey;
switch (taskchooserkey)
{
case 1:
cout << "Please choose : " << endl;
cout << "1. one account to another 1 <-> 1 " << endl
<< "2. one account to all other accounts 1 -> 2,3,4,5,6 " << endl
<< "3. all accounts to one accout 2,3,4,5,6 -> 1" << endl
<< "4. add in one account 1 ++ $ " << endl
<< "5. minus from one accout 1 -- $ " << endl
<< "Enter your key : ";
cin >> transactionkey;
cout << endl;
switch (transactionkey)
{
case 1:
cout << "Enter amount > ";
cin >> transferamount;
cout << "tranfer for money works like : " << endl;
cout << " player no. -> player no." << endl;
for (int vai = 0; vai < 369; vai++)
{
cout << "Enter player number of whom you want to take money -- " << endl;
cin >> atpid;
if (atpid > 0 && atpid <= totalplayers)
{
break;
}
}
switch (atpid)
{
case 1:
player[0].minusmoney(transferamount);
break;
case 2:
player[1].minusmoney(transferamount);
break;
case 3:
player[2].minusmoney(transferamount);
break;
case 4:
player[3].minusmoney(transferamount);
break;

case 5:
player[4].minusmoney(transferamount);
break;
case 6:
player[5].minusmoney(transferamount);
break;
}
for (int wvai = 0; wvai < 369; wvai++)
{
cout << "Enter player number to give money -- " << endl;
cin >> atpid_1;
if (atpid_1 > 0 && atpid_1 <= totalplayers)
{
break;
}
}
switch (atpid_1)
{
case 1:
player[0].addmoney(transferamount);
break;
case 2:
player[1].addmoney(transferamount);
break;
case 3:
player[2].addmoney(transferamount);
break;
case 4:
player[3].addmoney(transferamount);
break;

case 5:
player[4].addmoney(transferamount);
break;
case 6:
player[5].addmoney(transferamount);
break;
}

break; // switch transactionkey case 2
case 2:
cout << "Enter transfer amount -- ";
cin >> transferamount;
cout << endl;
for (int wqvai = 0; wqvai < 369; wqvai++)
{
cout << "Enter player number of whow you want to take money from -- " << endl;
cin >> atpid;
if (atpid > 0 && atpid <= totalplayers)
{
break;
}
}
switch (atpid)
{
case 1:
player[0].minusmoney(transferamount);
break;
case 2:
player[1].minusmoney(transferamount);
break;
case 3:
player[2].minusmoney(transferamount);
break;
case 4:
player[3].minusmoney(transferamount);
break;

case 5:
player[4].minusmoney(transferamount);
break;
case 6:
player[5].minusmoney(transferamount);
break;
}
switch (atpid)
{
case 1:
player[1].addmoney(transferamount);
player[2].addmoney(transferamount);
player[3].addmoney(transferamount);
player[4].addmoney(transferamount);
player[5].addmoney(transferamount);
break;
case 2:
player[0].addmoney(transferamount);
player[2].addmoney(transferamount);
player[3].addmoney(transferamount);
player[4].addmoney(transferamount);
player[5].addmoney(transferamount);
break;
case 3:
player[1].addmoney(transferamount);
player[0].addmoney(transferamount);
player[3].addmoney(transferamount);
player[4].addmoney(transferamount);
player[5].addmoney(transferamount);
break;
case 4:
player[1].addmoney(transferamount);
player[2].addmoney(transferamount);
player[0].addmoney(transferamount);
player[4].addmoney(transferamount);
player[5].addmoney(transferamount);
break;
case 5:
player[1].addmoney(transferamount);
player[2].addmoney(transferamount);
player[3].addmoney(transferamount);
player[0].addmoney(transferamount);
player[5].addmoney(transferamount);
break;
case 6:
player[1].addmoney(transferamount);
player[2].addmoney(transferamount);
player[3].addmoney(transferamount);
player[4].addmoney(transferamount);
player[0].addmoney(transferamount);
break;
}
break; // switch for transactionkey case 2
case 3:
cout<<"Enter amount to transfer -- ";
cin>>transferamount;
cout<<endl;
for (int wqvait = 0; wqvait < 369; wqvait++)
{
cout << "Enter player number to add money -- " << endl;
cin >> atpid;
if (atpid > 0 && atpid <= totalplayers)
{
break;
}
}
switch (atpid)
{
case 1:
player[0].addmoney(transferamount);
break;
case 2:
player[1].addmoney(transferamount);
break;
case 3:
player[2].addmoney(transferamount);
break;
case 4:
player[3].addmoney(transferamount);
break;

case 5:
player[4].addmoney(transferamount);
break;
case 6:
player[5].addmoney(transferamount);
break;
}
switch (atpid)
{
case 1:
player[1].minusmoney(transferamount);
player[2].minusmoney(transferamount);
player[3].minusmoney(transferamount);
player[4].minusmoney(transferamount);
player[5].minusmoney(transferamount);
break;
case 2:
player[0].minusmoney(transferamount);
player[2].minusmoney(transferamount);
player[3].minusmoney(transferamount);
player[4].minusmoney(transferamount);
player[5].minusmoney(transferamount);
break;
case 3:
player[1].minusmoney(transferamount);
player[0].minusmoney(transferamount);
player[3].minusmoney(transferamount);
player[4].minusmoney(transferamount);
player[5].minusmoney(transferamount);
break;
case 4:
player[1].minusmoney(transferamount);
player[2].minusmoney(transferamount);
player[0].minusmoney(transferamount);
player[4].minusmoney(transferamount);
player[5].minusmoney(transferamount);
break;
case 5:
player[1].minusmoney(transferamount);
player[2].minusmoney(transferamount);
player[3].minusmoney(transferamount);
player[0].minusmoney(transferamount);
player[5].minusmoney(transferamount);
break;
case 6:
player[1].minusmoney(transferamount);
player[2].minusmoney(transferamount);
player[3].minusmoney(transferamount);
player[4].minusmoney(transferamount);
player[0].minusmoney(transferamount);
break;
}

break;
case 4:
cout<<"Enter amount to add -- ";
cin>>transferamount;
cout<<endl;
for (int wqvait = 0; wqvait < 369; wqvait++)
{
cout << "Enter player number to add money -- " << endl;
cin >> atpid;
if (atpid > 0 && atpid <= totalplayers)
{
break;
}
}
switch (atpid)
{
case 1:
player[0].addmoney(transferamount);
break;
case 2:
player[1].addmoney(transferamount);
break;
case 3:
player[2].addmoney(transferamount);
break;
case 4:
player[3].addmoney(transferamount);
break;

case 5:
player[4].addmoney(transferamount);
break;
case 6:
player[5].addmoney(transferamount);
break;
}
break;
case 5:
cout<<"Enter amount to take -- ";
cin>>transferamount;
cout<<endl;
for (int awqvait = 0; awqvait < 369; awqvait++)
{
cout << "Enter player number of whom you want to take money -- " << endl;
cin >> atpid;
if (atpid > 0 && atpid <= totalplayers)
{
break;
}
}
switch (atpid)
{
case 1:
player[0].minusmoney(transferamount);
break;
case 2:
player[1].minusmoney(transferamount);
break;
case 3:
player[2].minusmoney(transferamount);
break;
case 4:
player[3].minusmoney(transferamount);
break;

case 5:
player[4].minusmoney(transferamount);
break;
case 6:
player[5].minusmoney(transferamount);
break;
}


break;
default:
goto taskchooser;
break;
}
break;
case 2:
for (int sl = 0; sl < totalplayers; sl++)
{
player[sl].showdetail();
}

default:
goto taskchooser;
}
goto taskchooser;
return 0;
Tags

Post a Comment

0Comments

Please Select Embedded Mode To show the Comment System.*