Advertisement
programusy

Untitled

Apr 12th, 2023
21
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class produkt
  6. {
  7. public:
  8. double wartosc;
  9. double ciezar;
  10. double limit;
  11. string nazwa;
  12.  
  13. double wyswietl();
  14. produkt(double w, double c, double l, string n);
  15. };
  16.  
  17. produkt::produkt(double w, double c, double l, string n)
  18. {
  19. wartosc = w;
  20. ciezar = c;
  21. limit = l;
  22. nazwa = n;
  23. }
  24.  
  25. double produkt::wyswietl()
  26. {
  27. cout << "Nazwa: " << nazwa << ", wartosc: " << wartosc << ", ciezar: " << ciezar << ", limit: " << limit << endl;
  28. }
  29.  
  30. int main()
  31. {
  32. produkt p1(5,0.5,5,"maka");
  33. produkt p2(6,0.3,4,"kasza");
  34. produkt p3(2,1.5,15,"sol");
  35. produkt p4(10,1.2,10,"cukier");
  36. produkt p5(20,0.1,2.5,"herbata");
  37.  
  38. p1.wyswietl();
  39. p2.wyswietl();
  40. p3.wyswietl();
  41. p4.wyswietl();
  42. p5.wyswietl();
  43. //cout << p1.nazwa << ", " << p1.ciezar << ", " << p1.limit << ", " << p1.wartosc << endl;
  44. return 0;
  45. }
  46.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement