Advertisement
Guest User

Untitled

a guest
Nov 20th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.96 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. class gracz {
  6. private:
  7. string nick;
  8. string ip;
  9. int liczba_banow;
  10. int typ_konta;
  11. int exp;
  12. public:
  13. void setNick(string n){
  14. nick = n;
  15. }
  16. void setIp(string i){
  17. ip = i;
  18. }
  19. void setLiczba_banow(int l){
  20. liczba_banow = l;
  21. }
  22. void setTyp_konta(int t){
  23. typ_konta = t;
  24. }
  25. void setExp(int e){
  26. exp = e;
  27. }
  28. string getNick(){
  29. return nick;
  30. }
  31. string getIp(){
  32. return ip;
  33. }
  34. int getLiczba_banow(){
  35. return liczba_banow;
  36. }
  37. int getTyp_konta(){
  38. return typ_konta;
  39. }
  40. int getExp(){
  41. return exp;
  42. }
  43. void Walka(); // metoda
  44. void Ban(); //metoda
  45. gracz() { // konstruktor
  46. cout << "Dodano nowego gracza. ";
  47. exp = 0;
  48. liczba_banow = 0;
  49. nick = "nick";
  50. }
  51. ~gracz() { //destrutkor
  52. cout << "Konto gracza " << nick << " usunięte";
  53. };
  54.  
  55. };
  56.  
  57. class wojownik //pochodna od gracz
  58. : public gracz
  59. {
  60. string nick = "wojownik";
  61. string ip = "127.1.1.1";
  62. int liczba_banow = 0;
  63. int exp = 10;
  64. public:
  65. gracz::Walka() { TU COS NIE PYKA
  66. x=rand()%2+0;
  67. if(x=1) {
  68. cout << "Zwycięstwem. Gracz " << nick <<" zdobył 10 pkt. doświadczenia."
  69. exp += 10;
  70. }
  71. else {
  72. cout << "uuuu... przegrałeś."
  73. };
  74. }
  75. };
  76.  
  77. class czarodziej
  78. : public gracz
  79. {
  80. string nick = "czarodziej"; // przypisywanie zmiennych
  81. string ip = "10.255.120.1";
  82. int liczba_banow = 0;
  83. int exp = 20;
  84. public:
  85. };
  86. int main()
  87. {
  88.  
  89. }
  90. ||=== Build: Debug in LAB 1 (compiler: GNU GCC Compiler) ===|
  91. D:\Projekty C++\LAB 1\main.cpp|60|warning: non-static data member initializers only available with -std=c++11 or -std=gnu++11|
  92. D:\Projekty C++\LAB 1\main.cpp|61|warning: non-static data member initializers only available with -std=c++11 or -std=gnu++11|
  93. D:\Projekty C++\LAB 1\main.cpp|62|warning: non-static data member initializers only available with -std=c++11 or -std=gnu++11|
  94. D:\Projekty C++\LAB 1\main.cpp|63|warning: non-static data member initializers only available with -std=c++11 or -std=gnu++11|
  95. D:\Projekty C++\LAB 1\main.cpp|65|error: cannot define member function 'gracz::Walka' within 'wojownik'|
  96. D:\Projekty C++\LAB 1\main.cpp|80|warning: non-static data member initializers only available with -std=c++11 or -std=gnu++11|
  97. D:\Projekty C++\LAB 1\main.cpp|81|warning: non-static data member initializers only available with -std=c++11 or -std=gnu++11|
  98. D:\Projekty C++\LAB 1\main.cpp|82|warning: non-static data member initializers only available with -std=c++11 or -std=gnu++11|
  99. D:\Projekty C++\LAB 1\main.cpp|83|warning: non-static data member initializers only available with -std=c++11 or -std=gnu++11|
  100. ||=== Build failed: 1 error(s), 8 warning(s) (0 minute(s), 0 second(s)) ===|
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement