Advertisement
Guest User

Untitled

a guest
Mar 19th, 2014
395
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.00 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string>
  4. #include <vector>
  5. #include <stdlib.h>
  6. #include <algorithm>
  7. #include <ctime>
  8. int you = 0;
  9. int pc = 0;
  10. using namespace std;
  11. string lista[] = {"koniec", "kamien", "papier", "nozyce",};
  12. class GRACZ {
  13. public :
  14. int punkty;
  15.     int komputer(){srand (time (NULL) );int a = (rand()%3) + 1; cout << "komputer : " << lista[a] << endl; return a;}
  16. int player(){int b; cout << "wybierz" << endl; cin >> b; cout << "player : " << lista[b] << endl; return b;}
  17. };
  18. class GRA{
  19.     public :
  20. void printmenu(){   cout << "1) Kamien" << endl << "2) Papier" << endl << "3) Nozyce" << endl;}
  21. int compare(int c, int d)
  22. {
  23. if ((c==1 && c==3) || (c==2 && d==1) || (c==3 && d==2)){ cout << "wygrales" << endl; you++;}
  24. if (c == d) cout << "remis" << endl;
  25. else {cout << "przegrales" << endl; pc++;}
  26. cout << "YOU : " << you << " PC : " << pc <<endl;
  27. }
  28. };
  29.  
  30. int main(void)
  31. {
  32.     GRA().printmenu();
  33.     int a = GRACZ().player();
  34.     int b = GRACZ().komputer();
  35. GRA().compare(a,b);
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement