Advertisement
madalinaradu

POO lab 19 martie Static magazin cu prod

Mar 19th, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.21 KB | None | 0 0
  1. #include <cstdlib>
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6.  
  7. class Produs{
  8. private:
  9.     char nume[100];
  10.     float pret; //fara TVA, in Euro
  11.     static float PROCENT_TVA;
  12.     static float CURS_VALUTAR;
  13. public:
  14.     Produs(char *nume, float pret);//constructor
  15.     //Produs(Produs &x); //constr copiere
  16.     //~Produs();
  17.     void citire();
  18.     void afisare();
  19.     static float getCURS_VALUTAR();
  20.     static void setCURS_VALUTAR(float CURS_VALUTAR);
  21.     float getPretCuTVA(){
  22.         return pret*(1+PROCENT_TVA);
  23.     }
  24.  
  25.     float getPretLeiCuTVA(){
  26.         return getPretCuTVA()*CURS_VALUTAR;
  27.     }
  28. };
  29. float Produs::PROCENT_TVA = 0.19;
  30. float Produs::CURS_VALUTAR = 4.7;
  31.  
  32.  
  33. Produs::Produs(char *nume, float pret){
  34. strcpy(this -> nume, nume);
  35. this -> pret = pret;
  36. }
  37.  
  38. void Produs::afisare(){
  39.         printf("Nume: %s\n", nume);
  40.         printf("Pret in Euro fara TVA: %g\n", pret);
  41.         //printf("Pret in Euro cu TVA: %g\n", getPretCuTVA());
  42.         printf("Pret Lei cu TVA: %g\n", getPretLeiCuTVA());
  43.     }
  44.  
  45.  
  46.  
  47. int main(){
  48. Produs p1("CPU", 100);
  49. Produs p2("HDD", 200);
  50. p1.afisare();
  51. p2.afisare();
  52. Produs:: PROCENT_TVA = 0.25; Inaccesibil!
  53. Produs::setTVA(0.25);
  54. p1.afisare();
  55. p2.afisare();
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement