Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Produkt
- {
- public:
- string nazwa;
- double cena, ilosc;
- Produkt();
- Produkt(string, double, double);
- void zmien_ilosc();
- void pokaz_produkt();
- };
- class Paragon
- {
- string kasjer;
- Produkt *tab;
- string data;
- double suma;
- int ile;
- public:
- Paragon();
- Paragon(string, string);
- void policz_rachunek();
- void dodaj_do_koszyka(Produkt);
- void pokaz_paragon();
- };
- int main()
- {
- Produkt A("Papierosy",15.45,5.0);
- Produkt B("Wódka", 30.00, 5.0);
- Produkt C("Wino", 60.00, 1.0);
- Produkt D("Cygara", 1200.00, 2.0);
- Produkt E("Kokaina", 400.00, 3.0);
- Paragon F("Maciek XYZ", "24.03.2015");
- F.dodaj_do_koszyka(A);
- F.dodaj_do_koszyka(B);
- F.dodaj_do_koszyka(E);
- F.pokaz_paragon();
- return 0;
- }
- void Produkt::zmien_ilosc()
- {
- cin>>ilosc;
- }
- void Produkt::pokaz_produkt()
- {
- cout<<nazwa<<" "<<cena<<" zł"<<ilosc<<" "<<endl;
- }
- void Paragon::pokaz_paragon()
- {
- cout<<kasjer<<endl;
- cout<<data<<endl;
- for(int i=0; i<ile; i++)
- {
- cout<<tab[i].nazwa<<" "<<tab[i].cena<<" "<<tab[i].ilosc<<" "<<endl;
- }
- cout<<suma<<" zł"<<endl;
- }
- void Paragon::policz_rachunek()
- {
- for (int i=0;i<ile;i++)
- {
- suma=tab[i]*cena;
- }
- cout<<suma<<" zł"<<endl;
- }
- void Paragon::dodaj_do_koszyka(Produkt G)
- {
- tab[ile]=G;
- ile++;
- }
- Paragon::Paragon()
- {
- tab= new Produkt[1];
- for(int i=0;i<1;i++)
- {
- tab[i]=Produkt();
- }
- kasjer=" ";
- data=" ";
- suma=0.0;
- ile =0;
- }
- Paragon::Paragon(string k, string dat)
- {
- ile=0;
- tab=new Produkt[10];
- for(int i=0;i<10;i++)
- {
- tab[i]=Produkt();
- }
- kasjer=k;
- data=dat;
- suma=0.0;
- }
- Produkt::Produkt()
- {
- nazwa=" ";
- cena=0.0;
- ilosc=0.0;
- }
- Produkt::Produkt(string n,double c, double il)
- {
- nazwa=n;
- cena=c;
- ilosc=il;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement