SHARE
TWEET

Untitled

a guest Jun 13th, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. using namespace std;
  3. /*Scrieti un program in care sa utilizati urmatoarele clase:
  4. -Avioane(clasa de baza) cu datele memv=bre: fabricant, model, pret
  5. -Pasageri (clasa derivata din aavioane) cu datele membre: numar pasageri etajat, numar membrii echipaj
  6. -Marfa( clasa derivata din avioane) cu datele membre: capacitate(m^3), tonaj(t)
  7. Creati urmatoarele functii membre: constructori faar parametrii, constructori cu parametrii, functii de acces oentru toate datele membre
  8. Supraincarcato operatorul <<
  9. Afisati continutul obiectelor cu operatorul supraincarcat3
  10.  
  11. */
  12.  
  13.  
  14. class avioane{
  15. public:
  16. string fabricant;
  17. string model;
  18. int pret;
  19.  
  20. avioane (){fabricant="Necunoscut";model="Necunoscut";pret=0;}
  21. avioane(string fabr,string mod,int pr){fabricant=fabr;model=mod;pret=pr;}
  22.  
  23. void set_fabricant(string fabr){fabricant=fabr;}
  24. void set_model(string mod){model=mod;}
  25. void set_pret(int pr){pret=pr;}
  26.  
  27. string get_fabricant(){return fabricant;}
  28. string get_model(){return model;}
  29. int get_pret(){return pret;}
  30.  
  31. friend ostream& operator<<(ostream &,const avioane &);
  32. };
  33.  
  34.  
  35. class pasageri : public avioane{
  36. private:
  37.     int nr_psg_etajat;         //numar pasageri..
  38.     int nr_psg_echipaj;
  39. public:
  40.     pasageri(){nr_psg_etajat=0;nr_psg_echipaj=0;}
  41.     pasageri(int nrpaset,int nrpasec,string mdl,string fbr,int pr ):nr_psg_etajat(nrpaset),nr_psg_echipaj(nrpasec),avioane(fbr,mdl,pr){//mdl-model;  fbr-fabricant; pr=pret
  42.  
  43. }
  44. void set_nrpsg1(int nrpsgetj){nr_psg_etajat=nrpsgetj;}
  45. void set_nrpsg2(int nrpsgech){nr_psg_echipaj=nrpsgech;}
  46.  
  47. int get_nrpsg1(){return nr_psg_etajat;}//nrpsg1-numarul asagerilor etajati
  48. int get_nrpsg2(){return nr_psg_echipaj;}//nrpsg2- numarul pasagerilor echipaj
  49.  
  50.  
  51. friend ostream& operator<<(ostream &,const pasageri &);
  52. };
  53.  
  54.  
  55. class marfa : public avioane{
  56. private:
  57.     float capacitate;
  58.     float tonaj;
  59. public:
  60.     marfa(){capacitate=0;tonaj=0;}
  61.     marfa(float capacit,float tona,string mdl,string fbr,int pr ):capacitate(capacit),tonaj(tona),avioane(fbr,mdl,pr){
  62.  
  63. }
  64.  
  65. void set_capacitate(float capac){capacitate=capac;}
  66. void set_tonaj(float tona){tonaj=tona;}
  67.  
  68. float get_capacitate(){return capacitate;}
  69. float get_tonaj(){return tonaj;}
  70.  
  71.  
  72.  
  73. friend ostream& operator<<(ostream &,const marfa &);
  74.  
  75. };
  76.  
  77. ostream& operator<<(ostream &p,const avioane &av)
  78. {
  79.     p<<"Fabricant:"<<av.fabricant<<"; Model:"<<av.model<<" Pret:"<<av.pret<<" milioane dolari ";
  80.     return p;
  81. }
  82. ostream& operator<<(ostream &p,const pasageri &pas)
  83. {
  84.     p<<avioane(pas)<<"; Numar pasageri etajati:"<<pas.nr_psg_etajat<<"; Numar pasageri echipaj:"<<pas.nr_psg_echipaj;
  85.     return p;
  86. }
  87. ostream& operator<<(ostream &p,const marfa &mar)
  88. {
  89.     p<<avioane(mar)<<"; Capacitate:"<<mar.capacitate<<" m^3"<<"; Tonaj:"<<mar.tonaj<<" tone";
  90.     return p;
  91. }
  92.  
  93.  
  94.  
  95.  
  96. int main(){
  97.  
  98.     pasageri psg(156,15,"Boeing 727","Boeing Commercial Airplanes",22);
  99.           cout<<psg<<endl;
  100.     marfa mrf(28.698,70.53,"Boeing 727","Boeing Commercial Airplanes",22);
  101.           cout<<mrf;
  102.  
  103.  
  104.     return 0;}
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top