Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <time.h> // srand() rand()
- #include <windows.h> // Sleep()
- using namespace std;
- class Money;
- int wypelnij(int[],const int);
- int JustSame(int[],const int);
- void ifSame(int[],const int,Money&);
- void shop(Money&);
- void Game(Money&);
- void Stats(Money&);
- void levelup(Money&);
- void failed(Money&);
- class Money{
- public:
- int gold;
- int level;
- int expMin;
- int expMax;
- Money(int g,int l,int eMin,int eMax){
- gold=g;
- level=l;
- expMin=eMin;
- expMax=eMax;
- }
- };
- int main()
- {
- Money kasa(100,1,0,10);
- srand(time(NULL));
- Game(kasa);
- return 0;
- }
- void Game(Money& x){
- levelup(x);
- system("cls");
- int n = 10;
- int tab[n];
- int c=0;
- Stats(x);
- cout<<"\nprint 1 to start game\n";
- cout<<"\nprint 2 go to shop\n";
- cout<<"Enter: ";
- cin >>c;
- switch(c){
- case 1:
- {
- wypelnij(tab,n);
- cout<<"\nwait...\n";
- Sleep(5000);
- system("cls");
- ifSame(tab,n,x);
- break;
- }
- case 2:
- {
- cout<<"\nwait...\n";
- Sleep(5000);
- system("cls");
- shop(x);
- break;
- }
- default:
- {
- cout << "unknown error";exit(0);
- }
- }
- }
- void levelup(Money& x){
- if(x.expMin >= x.expMax){
- if(x.expMin > x.expMax){
- int bs=0;
- bs=x.expMin-x.expMax;
- x.expMin=0;
- x.expMax*=2;
- x.expMin+=bs;
- }else {x.expMin=0;x.expMax*=2;};
- x.level+=1;
- cout <<"Congratulations! You have reached a higher level!\n";
- Sleep(5000);
- return Game(x);
- }
- }
- void Stats(Money& x){
- cout << "Money: "<<x.gold<<endl;
- cout<< "---------\n";
- cout<<"Exp:"<<x.expMin<<"/"<<x.expMax<<endl;
- cout<<"Level: "<<x.level<<endl;
- }
- void shop(Money& x){
- levelup(x);
- int printme=0;
- cout << "|print 1| (100 gold : 1 exp)\n";
- cout << "|print 2| (500 gold : 5 exp)\n";
- cout << "|print 3| (1500 gold : 15 exp)\n";
- cout << "|print 4| (5000 gold : 50 exp)\n";
- cout << "|print 5| (10000 gold : 100 exp)\n";
- cout<< "Enter: ";
- cin >> printme;
- if(printme == 1 && x.gold >= 100){
- cout << "successful transaction!\n";
- x.expMin+=1;
- x.gold-=100;
- Sleep(3000);
- return Game(x);
- }else if(printme == 1 && x.gold < 100){
- failed(x);
- }
- if(printme == 2 && x.gold >= 500){
- cout << "successful transaction!\n";
- x.expMin+=5;
- x.gold-=500;
- Sleep(3000);
- return Game(x);
- }else if(printme == 2 && x.gold < 500){
- failed(x);
- }
- if(printme == 3 && x.gold >= 1500){
- cout << "successful transaction!\n";
- x.expMin+=15;
- x.gold-=1500;
- Sleep(3000);
- return Game(x);
- }else if(printme == 3 && x.gold < 1500){
- failed(x);
- }
- if(printme == 4 && x.gold >= 5000){
- cout << "successful transaction!\n";
- x.expMin+=50;
- x.gold-=5000;
- Sleep(3000);
- return Game(x);
- }else if(printme == 4 && x.gold < 5000){
- failed(x);
- }
- if(printme == 5 && x.gold >= 10000){
- cout << "successful transaction!\n";
- x.expMin+=100;
- x.gold-=10000;
- Sleep(3000);
- return Game(x);
- }else if(printme == 5 && x.gold < 10000){
- failed(x);
- }else {cout << "unknown error\n";exit(0);}
- }
- void failed(Money& x){
- cout << "sorry but you don't have enough money!\n";
- Sleep(3000);
- return Game(x);
- }
- int wypelnij(int tab[],const int n)
- {
- int losowa=0;
- for(int i=0; i<n; i++)
- {
- losowa = rand()%100+1;
- tab[i]=losowa;
- }
- return* tab;
- }
- int JustSame(int tab[],const int n)
- {
- int a=1;
- int numbs=0;
- for(int i=0; i<n; i++)
- {
- for(int j=a; j<n; j++)
- {
- if(tab[i]==tab[j])
- {
- numbs++;
- }
- }
- a++;
- }
- return numbs;
- }
- void ifSame(int tab[],const int n,Money& x)
- {
- cout<< "Waiting";
- for(int i=0; i<3; i++)
- {
- cout<<".";
- Sleep(1000);
- }
- if(JustSame(tab,n) == 1)
- {
- x.expMin+=1;
- system("cls");
- cout << "Jackpot!\n";
- cout << "Here your gold: "<<50<<endl;
- x.gold+=50;
- Sleep(3000);
- system("cls");
- return Game(x);
- }else if(JustSame(tab,n) == 2){
- x.expMin+=2;
- system("cls");
- cout << "Jackpot! x2\n";
- cout << "Here your gold: "<<100<<endl;
- x.gold+=100;
- Sleep(3000);
- system("cls");
- return Game(x);
- }else if(JustSame(tab,n) == 3){
- x.expMin+=3;
- system("cls");
- cout << "Jackpot! x3\n";
- cout << "Here your gold: "<<150<<endl;
- x.gold+=150;
- Sleep(3000);
- system("cls");
- return Game(x);
- }else if(JustSame(tab,n) == 4){
- x.expMin+=4;
- system("cls");
- cout << "Jackpot! x4\n";
- cout << "Here your gold: "<<300<<endl;
- x.gold+=300;
- Sleep(4000);
- system("cls");
- return Game(x);
- }else if(JustSame(tab,n) == 5){
- x.expMin+=10;
- system("cls");
- cout << "JACKPOT X5 !!!\n";
- cout << "Here your gold: "<<600<<endl;
- x.gold+=600;
- Sleep(6000);
- system("cls");
- return Game(x);
- }
- else
- {
- cout << "try again...\n";
- Sleep(2500);
- system("cls");
- return Game(x);
- }
- }
Add Comment
Please, Sign In to add comment