Advertisement
Guest User

Jebany paragon

a guest
Apr 26th, 2015
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class Produkt
  6. {
  7. public:
  8. string nazwa;
  9. double cena, ilosc;
  10. Produkt();
  11. Produkt(string, double, double);
  12. void zmien_ilosc();
  13. void pokaz_produkt();
  14. };
  15.  
  16. class Paragon
  17. {
  18. string kasjer;
  19. Produkt *tab;
  20. string data;
  21. double suma;
  22. int ile;
  23.  
  24. public:
  25. Paragon();
  26. Paragon(string, string);
  27. void policz_rachunek();
  28. void dodaj_do_koszyka(Produkt);
  29. void pokaz_paragon();
  30. };
  31. int main()
  32. {
  33. Produkt A("Papierosy",15.45,5.0);
  34. Produkt B("Wódka", 30.00, 5.0);
  35. Produkt C("Wino", 60.00, 1.0);
  36. Produkt D("Cygara", 1200.00, 2.0);
  37. Produkt E("Kokaina", 400.00, 3.0);
  38.  
  39. Paragon F("Maciek XYZ", "24.03.2015");
  40.  
  41. F.dodaj_do_koszyka(A);
  42. F.dodaj_do_koszyka(B);
  43. F.dodaj_do_koszyka(E);
  44. F.pokaz_paragon();
  45.  
  46. return 0;
  47. }
  48.  
  49. void Produkt::zmien_ilosc()
  50. {
  51. cin>>ilosc;
  52. }
  53.  
  54. void Produkt::pokaz_produkt()
  55. {
  56. cout<<nazwa<<" "<<cena<<" zł"<<ilosc<<" "<<endl;
  57. }
  58.  
  59. void Paragon::pokaz_paragon()
  60. {
  61. cout<<kasjer<<endl;
  62. cout<<data<<endl;
  63. for(int i=0; i<ile; i++)
  64. {
  65. cout<<tab[i].nazwa<<" "<<tab[i].cena<<" "<<tab[i].ilosc<<" "<<endl;
  66. }
  67. cout<<suma<<" zł"<<endl;
  68. }
  69.  
  70. void Paragon::policz_rachunek()
  71. {
  72. for (int i=0;i<ile;i++)
  73. {
  74. suma=tab[i]*cena;
  75. }
  76. cout<<suma<<" zł"<<endl;
  77. }
  78.  
  79. void Paragon::dodaj_do_koszyka(Produkt G)
  80. {
  81. tab[ile]=G;
  82. ile++;
  83. }
  84.  
  85. Paragon::Paragon()
  86. {
  87.  
  88. tab= new Produkt[1];
  89. for(int i=0;i<1;i++)
  90. {
  91. tab[i]=Produkt();
  92. }
  93. kasjer=" ";
  94. data=" ";
  95. suma=0.0;
  96. ile =0;
  97. }
  98.  
  99. Paragon::Paragon(string k, string dat)
  100. {
  101. ile=0;
  102. tab=new Produkt[10];
  103.  
  104. for(int i=0;i<10;i++)
  105. {
  106. tab[i]=Produkt();
  107. }
  108. kasjer=k;
  109. data=dat;
  110. suma=0.0;
  111. }
  112.  
  113. Produkt::Produkt()
  114. {
  115. nazwa=" ";
  116. cena=0.0;
  117. ilosc=0.0;
  118. }
  119.  
  120. Produkt::Produkt(string n,double c, double il)
  121. {
  122. nazwa=n;
  123. cena=c;
  124. ilosc=il;
  125. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement