Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <ctime>
- #include <windows.h>
- #include <fstream>
- #include <string>
- #include "conio.h"
- #include <stdio.h>
- #include <sstream>
- using namespace std;
- string x[12];
- int pieniadze;
- class Panel
- {
- string opcje[11];
- private:
- char w;
- void ustawOpcje()
- {
- opcje[0] = " PIENIADZE : ";
- opcje[1] = " ----------------- ";
- opcje[2] = " [AUKCJA] ";
- opcje[3] = " [GIELDA] ";
- opcje[4] = " [OLX] ";
- opcje[5] = " [SZYBKIE LOMPY] ";
- opcje[6] = " [SZYBKIE CZESCI] ";
- opcje[7] = " [LAKIERNIK] ";
- opcje[8] = " [POSTAC] ";
- opcje[9] = " [GARAZ] ";
- opcje[10] = " [KASYNO] ";
- }
- void wypiszOpcje()
- {
- {
- for(int i=0; i<11; i++)
- {
- string nic=" |";
- if(i==0)
- {
- x[i]=opcje[i];
- cout << x[i] << pieniadze << endl;
- }
- else
- {
- if(i==5)
- cout << nic << endl;
- else if(i==8)
- cout << nic << endl;
- int ile=opcje[i].size();
- nic.erase(0,ile);
- x[i]=opcje[i] + nic;
- cout << x[i] << endl;
- }
- }
- }
- }
- int poruszaniePanel(int & p)
- {
- system("cls");
- wypiszOpcje();
- w=getch();
- string poczatek=">";
- string koniec="<";
- switch(w)
- {
- case 'w':
- if(p==2)
- {
- break;
- }
- else
- {
- opcje[p-1].insert(0, poczatek);
- opcje[p].erase(0, 1);
- p-=1;
- }
- break;
- case 's':
- if(p==10)
- {
- break;
- }
- else
- {
- opcje[p+1].insert(0, poczatek);
- opcje[p].erase(0, 1);
- p+=1;
- }
- break;
- case 'c':
- return p;
- break;
- }
- }
- public:
- int glownaPanel(int poz)
- {
- ustawOpcje();
- opcje[poz].insert(0, ">");
- while(w!='c')
- {
- poruszaniePanel(poz);
- if(w=='c') {return poz; break;}
- }
- }
- };
- void wypiszX()
- {
- system("cls");
- cout << x[0] << pieniadze << endl;
- for(int i=1; i<12; i++)
- {
- if(i==5 || i==8) cout << " |" << endl;
- cout << x[i] << endl;
- }
- }
- string wysrodkuj(string tekst)
- {
- string nic = " ";
- int litery = tekst.length();
- nic.erase(0, litery);
- int ile=nic.length();
- nic.erase(0, ile/2);
- tekst.insert(0, nic);
- tekst.append(nic);
- return tekst;
- }
- void resetujX(int since, int to)
- {
- for(int i=since; i<to; i++)
- x[i].erase(24, 74);
- system("cls");
- wypiszX();
- }
- class Lomp
- {
- public:
- string marka;
- string model;
- string nazwa;
- string kolor;
- string paliwo;
- int cena;
- int rokprodukcji;
- int przebieg;
- int KM;
- float pojemnosc;
- string generujLompa()
- {
- int r=12;
- string mrk[r] = { "Audi ", "BMW ", "Fiat ", "Ford ", "Honda ", "Hyundai ", "Mazda ", "Nissan ", "Opel ", "Renault ", "Skoda ", "Volkswagen "};
- string mdl[r*3]= { "A6", "Q5", "S5",
- "M3", "X5", "Z4",
- "Grande Punto", "Seicento", "Panda",
- "Fiesta", "Focus", "Mustang",
- "Civic", "CRV", "Accord",
- "Tuscon", "ix35", "i30",
- "CX-5", "5", "MX-5",
- "Pulsar", "Qashqai", "X-Trail",
- "Astra", "Corsa", "Vectra",
- "Megane", "Clio", "Scenic",
- "Octavia", "Fabia", "Yeti",
- "Golf IV", "Passat B5", "Polo"
- };
- int los=rand()%r+0;
- int dodaj=rand()%3+0;
- marka = mrk[los];
- model = mdl[los*3+dodaj];
- return nazwa = marka+model;
- }
- void generujSpecs()
- {
- int r=12;
- int a=rand()%17+1;
- int b=rand()%50000+10000;
- string k[r] = { " bialy ", " brazowy ", " bezowy ", " czarny ", " czerwony ", " grafitowy ", " niebieski ", " srebrny ", " szary ", " zielony ", " zolty ", " zloty "};
- string p[r/3] = { " benzyna ", " diesel ", " hybryda ", " lpg " };
- int c=rand()%80000+13210;
- int rp=rand()%18+2000;
- int prz=a*b;
- int km=rand()%220+80;
- float poj=rand()%21/10.f+0.9;
- int los=rand()%r+0;
- kolor=k[los];
- paliwo=p[los/3];
- cena=c;
- rokprodukcji=rp;
- przebieg=prz;
- KM=km;
- pojemnosc=poj;
- }
- string konwertujCena()
- {
- stringstream ss;
- ss << cena;
- string c= ss.str();
- return c;
- }
- string konwertujRP()
- {
- stringstream ss;
- ss << rokprodukcji;
- string rp = ss.str();
- return rp;
- }
- string konwertujPrzebieg()
- {
- stringstream ss;
- ss << przebieg;
- string pg = ss.str();
- return pg;
- }
- string konwertujKM()
- {
- stringstream ss;
- ss << KM;
- string km = ss.str();
- return km;
- }
- string konwertujPojemnosc()
- {
- string po;
- stringstream ss;
- ss << pojemnosc;
- if(pojemnosc == 1 || pojemnosc == 2 || pojemnosc == 3) po = ss.str() + ".0";
- else po = ss.str();
- return po;
- }
- };
- class Aukcja
- {
- Lomp l[3];
- int cena;
- void generacjaLompa(int ile)
- {
- for(int i=0; i<ile; i++)
- {
- l[i].generujLompa();
- l[i].generujSpecs();
- }
- }
- void tworzLompy(int ktory)
- {
- x[1]+= wysrodkuj("Auto numer 1 : " + l[ktory].nazwa );
- x[2]+= wysrodkuj("Kolor : " + l[ktory].kolor);
- x[3]+= wysrodkuj("Rok produkcji : " + l[ktory].konwertujRP());
- x[4]+= wysrodkuj("Przebieg : " + l[ktory].konwertujPrzebieg() + "km");
- x[5]+= wysrodkuj("Silnik : " + l[ktory].konwertujPojemnosc() + " " + l[0].paliwo + " " + l[0].konwertujKM() + "KM");
- wypiszX();
- }
- string konwersjaCena(int jaka)
- {
- stringstream ss;
- cena=jaka;
- ss << cena;
- string c = ss.str();
- return c;
- }
- void graj()
- {
- pieniadze-=1000;
- resetujX(1, 4);
- Sleep(1000);
- Lomp l[3];
- generacjaLompa(3);
- tworzLompy(0);
- }
- public:
- char w;
- int glownaAukcja()
- {
- x[1]+= wysrodkuj("Na aukcji zobaczysz 3 auta, z ktorych tylko 1 mozesz kupic.");
- x[2]+= wysrodkuj("Cena poczatkowa to 500zl. Kazde kolejne podbicie to tez 500zl.");
- x[3]+= wysrodkuj("[1] Graj (wpisowe 1000zl)");
- wypiszX();
- w=getch();
- switch(w)
- {
- case '1':
- graj();
- break;
- case 'm':
- Panel pa;
- if(pa.glownaPanel(2)==2) glownaAukcja();
- break;
- }
- }
- };
- /*
- class Gielda
- {
- };
- class Olx
- {
- };
- class SzybkieLompy
- {
- };
- class SzybkieCzesci
- {
- };
- class Kasyno
- {
- };
- class Lakiernik
- {
- };
- */
- class Postac
- {
- public:
- int mech;
- int neg;
- int szcz;
- };
- class Garaz
- {
- public:
- int sloty;
- int ilosc_aut;
- string auta[];
- };
- void wczytajDane(Garaz & g, Postac & p, Panel & pa)
- {
- pieniadze=15000;
- p.mech=0;
- p.neg=0;
- p.szcz=0;
- g.ilosc_aut=0;
- g.sloty=1;
- }
- int main()
- {
- srand(time(NULL));
- Garaz gar;
- Postac pos;
- Panel pan;
- Aukcja auk;
- wczytajDane(gar, pos, pan);
- if(pan.glownaPanel(2)==2) auk.glownaAukcja();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement