Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <string>
- #include <vector>
- #include <stdlib.h>
- #include <algorithm>
- #include <ctime>
- int you = 0;
- int pc = 0;
- using namespace std;
- string lista[] = {"koniec", "kamien", "papier", "nozyce",};
- class GRACZ {
- public :
- int punkty;
- int komputer(){srand (time (NULL) );int a = (rand()%3) + 1; cout << "komputer : " << lista[a] << endl; return a;}
- int player(){int b; cout << "wybierz" << endl; cin >> b; cout << "player : " << lista[b] << endl; return b;}
- };
- class GRA{
- public :
- void printmenu(){ cout << "1) Kamien" << endl << "2) Papier" << endl << "3) Nozyce" << endl;}
- int compare(int c, int d)
- {
- if ((c==1 && c==3) || (c==2 && d==1) || (c==3 && d==2)){ cout << "wygrales" << endl; you++;}
- if (c == d) cout << "remis" << endl;
- else {cout << "przegrales" << endl; pc++;}
- cout << "YOU : " << you << " PC : " << pc <<endl;
- }
- };
- int main(void)
- {
- GRA().printmenu();
- int a = GRACZ().player();
- int b = GRACZ().komputer();
- GRA().compare(a,b);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement