Advertisement
LegoDrifter

Placebo koncert

Jun 28th, 2020
306
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 6.97 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3.  
  4. using namespace std;
  5.  
  6. class Koncert{
  7. protected:
  8.     char name[20];
  9.     char location[20];
  10.     static float season_discout;
  11.     float ticket_price;
  12. public:
  13.     Koncert(const char *name="",const char *location="",float ticket_price=0)
  14.     {
  15.         strcpy(this->name,name);
  16.         strcpy(this->location,location);
  17.         this->ticket_price=ticket_price;
  18.     }
  19.     Koncert(const Koncert &k)
  20.     {
  21.         strcpy(this->name,k.name);
  22.         strcpy(this->location,k.location);
  23.         this->ticket_price=k.ticket_price;
  24.     }
  25.     static void setSezonskiPopust(float number)
  26.     {
  27.         season_discout=number;
  28.     }
  29.     static float getSezonskiPopust()
  30.     {
  31.         return season_discout;
  32.     }
  33.     char *getNaziv()
  34.     {
  35.         return name;
  36.     }
  37.     virtual float cena()
  38.     {
  39.         return ticket_price *(1-season_discout);
  40.     }
  41.  
  42.     virtual int getType()
  43.     {
  44.         return 0;
  45.     }
  46.     virtual ~Koncert(){}
  47.     float getTicket()
  48.     {
  49.         return ticket_price;
  50.     }
  51.  
  52.  
  53.  
  54. };
  55. float Koncert::season_discout=0.2;
  56. class ElektronskiKoncert:public Koncert{
  57. private:
  58.     char *DJname;
  59.     float time;
  60.     bool dnevna_or_nokna;
  61. public:
  62.     ElektronskiKoncert(const char *name="",const char *location="",float ticket_price=0.0
  63.                        ,const char *DJname="",float time=0.0,bool dnevna_or_nokna=false):Koncert(name,location,ticket_price)
  64.     {
  65.         this->DJname = new char[strlen(DJname)+1];
  66.         strcpy(this->DJname,DJname);
  67.         this->dnevna_or_nokna=dnevna_or_nokna;
  68.         this->time=time;
  69.     }
  70.     ElektronskiKoncert(const ElektronskiKoncert &ek):Koncert(ek)
  71.     {
  72.         this->DJname = new char[strlen(ek.DJname)+1];
  73.         strcpy(this->DJname,ek.DJname);
  74.         this->dnevna_or_nokna=ek.dnevna_or_nokna;
  75.     }
  76.     float cena()
  77.     {
  78.         float dcena = Koncert::cena();
  79.         if(time>7)
  80.         {
  81.             dcena+=360;
  82.         }
  83.         else if(time>5)
  84.         {
  85.             dcena+=150;
  86.         }
  87.         if(dnevna_or_nokna)
  88.             dcena-=50;
  89.         else
  90.             dcena+=100;
  91.             return
  92.         dcena;
  93.  
  94.     }
  95.     char *getDJ()
  96.     {
  97.         return DJname;
  98.     }
  99.     int getType()
  100.     {
  101.         return 1;
  102.     }
  103.  
  104.  
  105. };
  106. void najskapKoncert(Koncert **koncerti,int n)
  107. {
  108.     int max=0;
  109.     int iMax=0;
  110.     int brojac=0;
  111.     for(int i=0;i<n;i++)
  112.     {
  113.         if(koncerti[i]->cena()>max)
  114.         {
  115.             max=koncerti[i]->cena();
  116.             iMax=i;
  117.         }
  118.         if(koncerti[i]->getType()==1)
  119.         {
  120.             brojac++;
  121.         }
  122.     }
  123.     cout<<"Najskap koncert: "<<koncerti[iMax]->getNaziv()<<" "<<koncerti[iMax]->cena()<<endl;
  124.     cout<<"Elektronski koncerti: "<<brojac<<" od vkupno "<<n;
  125. }
  126. bool prebarajKoncert(Koncert **koncerti,int n,const char *naziv,bool elektronski)
  127. {
  128.  
  129.     for(int i=0;i<n;i++)
  130.     {
  131.         if(elektronski==true)
  132.         {
  133.             if(koncerti[i]->getType()==1)
  134.             {
  135.                 if(strcmp(koncerti[i]->getNaziv(),naziv)==0)
  136.                 {
  137.                 cout<<koncerti[i]->getNaziv()<<" "<<koncerti[i]->cena()<<endl;
  138.  
  139.                 return true;
  140.                 }
  141.             }
  142.         }
  143.         else if(elektronski==false)
  144.         {
  145.             if(strcmp(koncerti[i]->getNaziv(),naziv)==0)
  146.             {
  147.                 cout<<koncerti[i]->getNaziv()<<" "<<koncerti[i]->cena()<<endl;
  148.  
  149.                 return true;
  150.             }
  151.         }
  152.  
  153.     }
  154.        
  155.         return false;
  156.  
  157. }
  158. int main(){
  159.  
  160.     int tip,n,novaCena;
  161.     char naziv[100], lokacija[100], imeDJ[40];
  162.     bool dnevna;
  163.     float cenaBilet, novPopust;
  164.     float casovi;
  165.  
  166.         cin>>tip;
  167.         if (tip==1){//Koncert
  168.             cin>>naziv>>lokacija>>cenaBilet;
  169.             Koncert k1(naziv,lokacija,cenaBilet);
  170.             cout<<"Kreiran e koncert so naziv: "<<k1.getNaziv()<<endl;
  171.         }
  172.         else if (tip==2){//cena - Koncert
  173.             cin>>naziv>>lokacija>>cenaBilet;
  174.             Koncert k1(naziv,lokacija,cenaBilet);
  175.             cout<<"Osnovna cena na koncertot so naziv "<<k1.getNaziv()<< " e: " <<k1.cena()<<endl;
  176.         }
  177.         else if (tip==3){//ElektronskiKoncert
  178.             cin>>naziv>>lokacija>>cenaBilet>>imeDJ>>casovi>>dnevna;
  179.             ElektronskiKoncert s(naziv,lokacija,cenaBilet,imeDJ,casovi,dnevna);
  180.             cout<<"Kreiran e elektronski koncert so naziv "<<s.getNaziv()<<" i sezonskiPopust "<<s.getSezonskiPopust()<<endl;
  181.         }
  182.         else if (tip==4){//cena - ElektronskiKoncert
  183.              cin>>naziv>>lokacija>>cenaBilet>>imeDJ>>casovi>>dnevna;
  184.              ElektronskiKoncert s(naziv,lokacija,cenaBilet,imeDJ,casovi,dnevna);
  185.              cout<<"Cenata na elektronskiot koncert so naziv "<<s.getNaziv()<<" e: "<<s.cena()<<endl;
  186.         }
  187.         else if (tip==5) {//najskapKoncert
  188.  
  189.         }
  190.         else if (tip==6) {//prebarajKoncert
  191.             Koncert ** koncerti = new Koncert *[5];
  192.             int n;
  193.             koncerti[0] = new Koncert("Area","BorisTrajkovski",350);
  194.             koncerti[1] = new ElektronskiKoncert("TomorrowLand","Belgium",8000,"Afrojack",7.5,false);
  195.             koncerti[2] = new ElektronskiKoncert("SeaDance","Budva",9100,"Tiesto",5,true);
  196.             koncerti[3] = new Koncert("Superhiks","PlatoUkim",100);
  197.             koncerti[4] = new ElektronskiKoncert("CavoParadiso","Mykonos",8800,"Guetta",3,true);
  198.             char naziv[100];
  199.             najskapKoncert(koncerti,5);
  200.         }
  201.         else if (tip==7){//prebaraj
  202.               Koncert ** koncerti = new Koncert *[5];
  203.             int n;
  204.             koncerti[0] = new Koncert("Area","BorisTrajkovski",350);
  205.             koncerti[1] = new ElektronskiKoncert("TomorrowLand","Belgium",8000,"Afrojack",7.5,false);
  206.             koncerti[2] = new ElektronskiKoncert("SeaDance","Budva",9100,"Tiesto",5,true);
  207.             koncerti[3] = new Koncert("Superhiks","PlatoUkim",100);
  208.             koncerti[4] = new ElektronskiKoncert("CavoParadiso","Mykonos",8800,"Guetta",3,true);
  209.             char naziv[100];
  210.             bool elektronski;
  211.             cin>>elektronski;
  212.             if(prebarajKoncert(koncerti,5, "Area",elektronski))
  213.                 cout<<"Pronajden"<<endl;
  214.             else cout<<"Ne e pronajden"<<endl;
  215.  
  216.             if(prebarajKoncert(koncerti,5, "Area",!elektronski))
  217.                 cout<<"Pronajden"<<endl;
  218.             else cout<<"Ne e pronajden"<<endl;
  219.  
  220.         }
  221.         else if (tip==8){//smeni cena
  222.               Koncert ** koncerti = new Koncert *[5];
  223.             int n;
  224.             koncerti[0] = new Koncert("Area","BorisTrajkovski",350);
  225.             koncerti[1] = new ElektronskiKoncert("TomorrowLand","Belgium",8000,"Afrojack",7.5,false);
  226.             koncerti[2] = new ElektronskiKoncert("SeaDance","Budva",9100,"Tiesto",5,true);
  227.             koncerti[3] = new Koncert("Superhiks","PlatoUkim",100);
  228.             koncerti[2] -> setSezonskiPopust(0.9);
  229.             najskapKoncert(koncerti,4);
  230.         }
  231.  
  232.     return 0;
  233. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement