Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- using namespace std;
- class Fotografija{
- private:
- char *opis;
- int rezolucija;
- int moment;
- public:
- Fotografija(char *opis="", int rezolucija=0, int moment=0)
- {
- this->opis=new char[strlen(opis)+1];
- strcpy(this->opis, opis);
- this->rezolucija=rezolucija;
- this->moment=moment;
- }
- Fotografija &operator=(Fotografija &ph)
- {
- if(this!=&ph)
- {
- delete [] this->opis;
- this->opis=new char[strlen(ph.opis)+1];
- strcpy(this->opis, ph.opis);
- this->rezolucija=ph.rezolucija;
- this->moment=ph.moment;
- }
- return *this;
- }
- void pecati()
- {
- cout<<getopis()<<endl;
- cout<<getrezolucija()<<endl;
- cout<<getmoment()<<endl;
- }
- int getrezolucija()
- {
- return this->rezolucija;
- }
- int getmoment()
- {
- return this->moment;
- }
- char *getopis()
- {
- return this->opis;
- }
- ~Fotografija()
- {
- delete [] this->opis;
- }
- };
- class Album{
- private:
- Fotografija *f;
- int vkupen;
- char ime[50];
- public:
- Album(Fotografija *f=0, int vkupen=0, char *ime="")
- {
- this->vkupen=vkupen;
- this->f=new Fotografija[this->vkupen];
- for(int i=0; i<this->vkupen; i++)
- {
- f[i]=f[i];
- }
- strcpy(this->ime, ime);
- }
- Album(const Album& a)
- {
- this->vkupen=a.vkupen;
- this->f=new Fotografija[a.vkupen];
- for(int i=0; i<a.vkupen; i++)
- {
- this->f[i]=a.f[i];
- }
- strcpy(this->ime, a.ime);
- }
- Album &operator=(Album &al)
- {
- if(this!=&al)
- {
- this->vkupen=al.vkupen;
- delete [] this->f;
- this->f=new Fotografija[al.vkupen];
- for(int i=0; i<al.vkupen; i++)
- {
- f[i]=al.f[i];
- }
- strcpy(this->ime, al.ime);
- }
- }
- void dodadifotografija(Fotografija o)
- {
- Fotografija *tmp= new Fotografija[this->vkupen];
- for(int i=0; i<this->vkupen; i++)
- {
- tmp[i]=this->f[i];
- }
- delete [] this->f;
- this->f=new Fotografija[this->vkupen+1];
- for(int i=0; i<this->vkupen; i++)
- {
- this->f[i]=tmp[i];
- }
- delete [] tmp;
- this->f[this->vkupen]=o;
- this->vkupen++;
- }
- void najgolemaFotografija()
- {
- int i;
- int naj=0;
- for (i=1;i<this->vkupen;i++)
- if ((f[i].getrezolucija())>(f[naj].getrezolucija()))
- naj=i;
- f[naj].pecati();
- }
- void fotografiiSlikani(int moment)
- {
- for(int i=0; i<this->vkupen; i++)
- {
- int n;
- n=f[i].getmoment();
- if(n>moment)
- {
- f[i].pecati();
- }
- }
- }
- int getvkupen()
- {
- return this->vkupen;
- }
- char *getime()
- {
- return this->ime;
- }
- ~Album()
- {
- delete [] this->f;
- }
- };
- int main()
- {
- int n;
- cout<<"Vnesete broj na sliki"<<endl;
- cin>>n;
- Fotografija f[n];
- char opis[100];
- int rezolucija;
- int moment;
- for(int i=0; i<n; i++)
- {
- cout<<"Vnesete opis"<<endl;
- cin>>opis;
- cout<<"Vnesete rezolucija"<<endl;
- cin>>rezolucija;
- cout<<"Vnesete moment"<<endl;
- cin>>moment;
- Fotografija t(opis, rezolucija, moment);
- f[i]=t;
- }
- char ime[30];
- cout<<"Vnesete ime na albumot"<<endl;
- cin>>ime;
- Album a(f, n, ime);
- a.najgolemaFotografija();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement