Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.90 KB | None | 0 0
  1. #include <iostream>
  2.  
  3.  
  4. using namespace std;
  5.  
  6.  
  7. /*
  8. 7. fie clasa EchipaDeFotbal care are ca atribute numele echipei, numele patronului
  9. si numar de trofee castigate. Fiecare jucator are un nume, un post pe care joaca si
  10. prima de joc.
  11. a. Creati un sir de echipe de fotbal si afisati sirul de echipe, pentru fiecare echipa se vor
  12. afisa informatiile despre fiecare jucator din echipa
  13. */
  14.  
  15. class EchipaDeFotbal
  16. {
  17. public:
  18.     string nume_echipa;
  19.     string nume_patron;
  20.     int nr_trofee;
  21.     int nr_jucatori;
  22.     string nume_jucator[1000];
  23.     string post_jucator[1000];
  24.     int prima_joc[1000];
  25.  
  26.     // Constructor fara parametri
  27.     EchipaDeFotbal(){ cout << "Constructor 1";}
  28.    
  29.     // Constructor cu parametri
  30.     EchipaDeFotbal(string nume_echipa_m, string nume_patron_m, int nr_trofee_m, int nr_jucatori_m,
  31.                     string nume_jucator_m[], string post_jucator_m[], int prima_joc_m[]) {
  32.         this->nume_echipa = nume_echipa_m;
  33.         this->nume_patron = nume_patron_m;
  34.         this->nr_trofee = nr_trofee_m;
  35.         this->nr_jucatori = nr_jucatori_m;
  36.  
  37.         for(int i=0; i<nr_jucatori_m; i++){
  38.             this->nume_jucator[i] = nume_jucator_m[i];
  39.             this->post_jucator[i] = post_jucator_m[i];
  40.             this->prima_joc[i] = prima_joc_m[i];
  41.         }
  42.     }
  43.  
  44.     void printInfoJucatori(){
  45.         for(int i=0; i<nr_jucatori; i++){
  46.             cout << "_____________Jucator " << i << "______\n";
  47.             cout << "Nume:" << nume_jucator[i] << "\n";
  48.             cout << "Post:" << post_jucator[i] << "\n";
  49.             cout << "Prima joc:" << prima_joc[i] << "\n";
  50.             cout << "________________________\n";
  51.         }
  52.        
  53.     }
  54. };
  55.  
  56.  
  57. int main(){
  58.     // EchipaDeFotbal E[1000];
  59.  
  60.     string nume_jucator_e1[2] = {"Ion", "Andrei"};
  61.     string post_jucator_e1[2] = {"portar", "jucator111"};
  62.     int prima_joc_e1[2] = {1200, 122};
  63.     string nume_echipa = "Echipa1";
  64.     string nume_patron = "Patronul 1";
  65.     EchipaDeFotbal e1(nume_echipa, nume_patron, 3, 2, nume_jucator_e1, post_jucator_e1, prima_joc_e1);
  66.     e1.printInfoJucatori();
  67.  
  68.     return 0;
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement