Filip_Markoski

Sports teams (Working)

Apr 19th, 2017
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.02 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3.  
  4. using namespace std;
  5.  
  6. class Ekipa {
  7. protected:
  8.     char name[15];
  9.     int defeats;
  10.     int wins;
  11. public:
  12.     Ekipa(const char *n = "", int w = 0, int d = 0) {
  13.         strcpy(name, n);
  14.         defeats = d;
  15.         wins = w;
  16.     }
  17.  
  18.     void pecati() {
  19.         cout << "Ime: " << name << " Pobedi: " << wins << " Porazi: " << defeats;
  20.     }
  21. };
  22.  
  23. class FudbalskaEkipa : public Ekipa {
  24. private:
  25.     int reds;
  26.     int yellows;
  27.     int draws;
  28. public:
  29.     FudbalskaEkipa(const char *n = "", int d = 0, int w = 0, int r = 0, int y = 0, int dr = 0) : Ekipa(n, d, w) {
  30.         reds = r;
  31.         yellows = y;
  32.         draws = dr;
  33.     }
  34.  
  35.     void pecati() {
  36.         Ekipa::pecati();
  37.         cout << " Nereseni: " << draws << " Poeni: " << wins * 3 + draws * 1 << endl;
  38.     }
  39. };
  40.  
  41. int main() {
  42.     char ime[15];
  43.     int pob, por, ck, zk, ner;
  44.     cin >> ime >> pob >> por >> ck >> zk >> ner;
  45.     FudbalskaEkipa f1(ime, pob, por, ck, zk, ner);
  46.     f1.pecati();
  47.     return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment