diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/dokument-novi standard/autorizovani.h b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/dokument-novi standard/autorizovani.h new file mode 100644 index 0000000..25bf6f2 --- /dev/null +++ b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/dokument-novi standard/autorizovani.h @@ -0,0 +1,24 @@ +#ifndef _AUTORIZOVANI_H_ +#define _AUTORIZOVANI_H_ + +#include "dokument.h" + +class Autorizovani : public Dokument { +protected: + string potpis; + + void pisi(ostream &it) const { + Dokument::pisi(it); + it << potpis; + } +public: + explicit Autorizovani(string pot, int kkap=5) : Dokument(kkap), potpis(pot) {} + + Autorizovani *kopija() const { return new Autorizovani(*this); } + + int duzina() const { + return Dokument::duzina() + potpis.length(); + } +}; + +#endif \ No newline at end of file diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/dokument-novi standard/dokument.h b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/dokument-novi standard/dokument.h new file mode 100644 index 0000000..d2ec180 --- /dev/null +++ b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/dokument-novi standard/dokument.h @@ -0,0 +1,89 @@ +#ifndef _DOKUMENT_H_ +#define _DOKUMENT_H_ + +#include + +#include +using namespace std; + +class Dokument { +private: + void brisi() { + if (pniz == nullptr) return; + delete [] pniz; + } + + void kopiraj(const Dokument &d); + + void premesti(Dokument &d) { + kap = d.kap; + pop = d.pop; + pniz = d.pniz; + d.pniz = nullptr; + } +protected: + int id; + static int ukId; + string *pniz; + int kap, pop; + + virtual void pisi(ostream &it) const; +public: + explicit Dokument(int kkap=5) { + kap = kkap; + pop = 0; + id = ukId++; + pniz = new string[kap]; + } + + virtual ~Dokument() { brisi(); } + + //kod svih mogucih nacina kopiranja objekta, obezbedjujemo jedinstvenost id broja + Dokument(const Dokument &d) { + id = ukId++; //uzme novi id + kopiraj(d); + } + + Dokument(Dokument &&d) { + id = ukId++; + premesti(d); + } + + Dokument &operator=(const Dokument &d) { + if (this != &d) { + brisi(); + kopiraj(d); + //ne kopira se id, svako vec ima svoj + } + return *this; + } + + Dokument &operator=(Dokument &&d) { + if (this != &d) { + brisi(); + premesti(d); + //ne kopira se id, svako vec ima svoj + } + return *this; + } + + virtual Dokument *kopija() const { return new Dokument(*this); } + + Dokument &operator+=(const string &s) { + if (kap == pop) exit(2); + pniz[pop++] = s; + return *this; + } + + int getPop() const { return pop; } + + //virtuelna, jer se drugacije racuna u izvedenoj klasi + virtual int duzina() const; + + friend ostream &operator<<(ostream &it, const Dokument &d) { + d.pisi(it); + return it; + } +}; + +#endif \ No newline at end of file diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/dokument-novi standard/main3.cpp b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/dokument-novi standard/main3.cpp new file mode 100644 index 0000000..1be95d0 --- /dev/null +++ b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/dokument-novi standard/main3.cpp @@ -0,0 +1,49 @@ +#include "dokument.h" +#include "autorizovani.h" +#include "zbirka.h" + +int main() { + while (true) { + cout << "Kapacitet (negativan za kraj): "; + int kap; + cin >> kap; + if (kap <=0) break; + + Zbirka zbirka(kap); + + int tip; + string potpis; + int k; + while (true) { + cout << "0.Kraj 1.Dokument 2.Autorizovani dokument: "; + cin >> tip; + if (tip != 1 && tip != 2) break; + + cout << "Kapacitet: "; + cin >> k; + getchar(); + + if (tip == 2) { cout << "Potpis: "; getline(cin, potpis); } + + Dokument *d = nullptr; + if (tip == 1) + d = new Dokument(k); + else + d = new Autorizovani(potpis, k); + + cout << "Unesi " << k << " pasusa: "; + string pasus; + for (int j=0; jduzina(); + return suma; +} + +ostream &operator<<(ostream &it, const Zbirka &z) { + for (int i=0; i> n; + if (n <= 0) break; + Mnogougao mn(n); + + for (int i=0; i> x >> y >> z; + mn += Vektor(x, y, z); + } + + cout << mn << endl; + + cout << "Obim: " << mn.duzina() << endl; + } + return 0; +} \ No newline at end of file diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/izlomljena linija-novi standard-nije provereno/metode2.cpp b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/izlomljena linija-novi standard-nije provereno/metode2.cpp new file mode 100644 index 0000000..1229dde --- /dev/null +++ b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/izlomljena linija-novi standard-nije provereno/metode2.cpp @@ -0,0 +1,30 @@ +#include "vektor.h" +#include "izlomljena.h" +#include "mnogougao.h" + +//ovde sigurno treba izvuci "duze" metode (sa petljom ili vecim brojem naredbi) +//ali generalno mogu sve metoda da se definisu ovde + +double Mnogougao::duzina() const { + if (pop == 0) return 0; //ako nije dodato nijedno teme + double suma = Izlomljena::duzina(); + suma += ~(temena[0]-temena[pop-1]);//dodamo razliku prvog i poslednje temena + return suma; +} + +double Izlomljena::duzina() const { + //kako se ovo radi, proveriti?? + double suma = 0; + for (int i=0; i + +#include +using namespace std; + +class Vektor { +private: + double x, y, z; +public: + explicit Vektor(double xx=0, double yy=0, double zz=0) { + x = xx; y = yy; z = zz; + } + + friend Vektor operator+(const Vektor &v1, const Vektor &v2) { + return Vektor(v1.x+v2.x, v1.y+v2.y, v1.z+v2.z); + } + + friend Vektor operator-(const Vektor &v1, const Vektor &v2) { + return Vektor(v1.x-v2.x, v1.y-v2.y, v1.z-v2.z); + } + + double operator~() const { + return sqrt(pow(x,2) + pow(y,2) + pow(z,2)); + } + + friend ostream &operator<<(ostream &it, const Vektor &v) { + return it << "(" << v.x << "," << v.y << "," << v.z << ")"; + } +}; + +#endif \ No newline at end of file diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/kupa-stari standard-nije idealno/kupa.h b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/kupa-stari standard-nije idealno/kupa.h new file mode 100644 index 0000000..5de454f --- /dev/null +++ b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/kupa-stari standard-nije idealno/kupa.h @@ -0,0 +1,30 @@ +#ifndef KUPA +#define KUPA + +#include +using namespace std; + +class Kupa { + virtual void pisi(ostream &it) { + it << r << "," << h; + } +protected: + double r, h; +public: + Kupa(double rr=1, double hh=2) { + r = rr; h = hh; + } + + virtual double zapremina() { return r*r*3.14*h/3; } + + bool operator<(Kupa &k) { + return zapremina() < k.zapremina(); + } + + friend ostream &operator<<(ostream &it, Kupa &k) { + k.pisi(it); + return it; + } +}; + +#endif \ No newline at end of file diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/kupa-stari standard-nije idealno/main1.cpp b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/kupa-stari standard-nije idealno/main1.cpp new file mode 100644 index 0000000..e989ce0 --- /dev/null +++ b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/kupa-stari standard-nije idealno/main1.cpp @@ -0,0 +1,43 @@ +#include "kupa.h" +#include "zkupa.h" +#include "skladiste.h" + +#include +using namespace std; + +void main() { + while (1) { + + Skladiste skl; + cout << "Koliko kupa? "; + int n; + cin >> n; + if (n <= 0) break; + + int i, izbor; + double r,h,d; + Kupa *k; + for (i=0; i> izbor; + cout << "r,h? "; + cin >> r >> h; + + if (izbor == 1) k = new Kupa(r,h); + else { + cout << "d?"; + cin >> d; + k = new ZKupa(r,h,d); + } + skl += k; + } + + cout << skl << endl; + + double v1, v2; + cout << "Zapremina v1, v2? "; + cin >> v1 >> v2; + + cout << "Broj: " << skl(v1, v2) << endl; + } +} \ No newline at end of file diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/kupa-stari standard-nije idealno/skladiste.h b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/kupa-stari standard-nije idealno/skladiste.h new file mode 100644 index 0000000..f6c3aa0 --- /dev/null +++ b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/kupa-stari standard-nije idealno/skladiste.h @@ -0,0 +1,63 @@ +#ifndef SKLADISTE +#define SKLADISTE +#include "kupa.h" + +struct Elem { + Kupa *sk; + Elem *sled; + + Elem(Kupa *skl) { + sk = skl; + sled = 0; + } +}; + +class Skladiste { + Elem *prvi, *posl; + + void brisi() { + Elem *stari; + while (prvi) { + stari = prvi; + prvi = prvi->sled; + delete stari->sk; + delete stari; + } + } + + Skladiste(Skladiste &s) {} + Skladiste &operator=(Skladiste &s) { return *this; } +public: + Skladiste() { prvi = posl = 0; } + + ~Skladiste() { brisi(); } + + Skladiste &operator+=(Kupa *k) { + Elem *novi = new Elem(k); + + if (prvi == 0) + prvi = posl = novi; + else { + posl->sled = novi; + posl = novi; + } + return *this; + } + + int operator()(double v1, double v2) { + int broj = 0; + for (Elem *tek=prvi; tek; tek=tek->sled) + if ((tek->sk->zapremina() > v1) && (tek->sk->zapremina() < v2)) broj++; + return broj; + } + + friend ostream &operator<<(ostream &it, Skladiste &s) { + it << "["; + for (Elem *tek=s.prvi; tek!=s.posl; tek=tek->sled) + it << *tek->sk << "|"; + it << *s.posl->sk << "]" << endl; + return it; + } +}; + +#endif \ No newline at end of file diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/kupa-stari standard-nije idealno/zkupa.h b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/kupa-stari standard-nije idealno/zkupa.h new file mode 100644 index 0000000..1f2864e --- /dev/null +++ b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/kupa-stari standard-nije idealno/zkupa.h @@ -0,0 +1,21 @@ +#ifndef ZKUPA +#define ZKUPA + +#include "kupa.h" + +#include +using namespace std; + +class ZKupa : public Kupa { + void pisi(ostream &it) { + it << r << "," << h << "," << d; + } +protected: + double d; +public: + ZKupa(double rr=1, double hh=2, double dd=1) : Kupa(rr, hh) { d = dd; } + + double zapremina() { return r*r*3.14*(h*h*h-d*d*d)/3*h*h; } +}; + +#endif \ No newline at end of file diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/kvadar lista-novi standard-druga verzija/Project2.sln b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/kvadar lista-novi standard-druga verzija/Project2.sln new file mode 100644 index 0000000..da6fbaa --- /dev/null +++ b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/kvadar lista-novi standard-druga verzija/Project2.sln @@ -0,0 +1,28 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26228.12 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Project2", "Project2\Project2.vcxproj", "{AF5B1A12-3381-40B2-BB52-9E4C02BC6BFE}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {AF5B1A12-3381-40B2-BB52-9E4C02BC6BFE}.Debug|x64.ActiveCfg = Debug|x64 + {AF5B1A12-3381-40B2-BB52-9E4C02BC6BFE}.Debug|x64.Build.0 = Debug|x64 + {AF5B1A12-3381-40B2-BB52-9E4C02BC6BFE}.Debug|x86.ActiveCfg = Debug|Win32 + {AF5B1A12-3381-40B2-BB52-9E4C02BC6BFE}.Debug|x86.Build.0 = Debug|Win32 + {AF5B1A12-3381-40B2-BB52-9E4C02BC6BFE}.Release|x64.ActiveCfg = Release|x64 + {AF5B1A12-3381-40B2-BB52-9E4C02BC6BFE}.Release|x64.Build.0 = Release|x64 + {AF5B1A12-3381-40B2-BB52-9E4C02BC6BFE}.Release|x86.ActiveCfg = Release|Win32 + {AF5B1A12-3381-40B2-BB52-9E4C02BC6BFE}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/kvadar lista-novi standard-druga verzija/Project2/20162kvadar.h b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/kvadar lista-novi standard-druga verzija/Project2/20162kvadar.h new file mode 100644 index 0000000..7d7c176 --- /dev/null +++ b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/kvadar lista-novi standard-druga verzija/Project2/20162kvadar.h @@ -0,0 +1,27 @@ +#pragma once +#include +#include +using namespace std; + +class kvadar { +protected: + int a; + int b; + int c; + void pisi(ostream &it) { + it << "K ( " << a << ", " << b << ", " << c << " )"; + } +public: + kvadar (int aa = 1, int bb = 1, int cc = 1) : a(aa), b(bb), c(cc) {} + int zapremina() { return a*b*c; } + friend ostream& operator<< (ostream& it, const kvadar &k) { + k.pisi(it); + return it; + } + friend bool operator==(const kvadar &k1, const kvadar &k2) { + if (k2.a == k1.a && k2.b == k1.b && k2.c == k1.c) + return true; + else return false; + } + //virtual kvadar* klon(kvadar&k) { return new kvadar(*this); } +}; \ No newline at end of file diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/kvadar lista-novi standard-druga verzija/Project2/20162lista.h b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/kvadar lista-novi standard-druga verzija/Project2/20162lista.h new file mode 100644 index 0000000..ad89b83 --- /dev/null +++ b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/kvadar lista-novi standard-druga verzija/Project2/20162lista.h @@ -0,0 +1,76 @@ +#pragma once +#include +#include +#include "20162kvadar.h" +using namespace std; + +class lista { +protected: + struct elem { + kvadar*pok; + elem*next; + elem(kvadar * p, elem * n = nullptr) { + pok = p; + next = n; + } + }; + elem*prvi; + elem*posl; + void brisi() { + elem*tek = prvi; + while (tek) { + elem*stari = tek; + tek = tek->next; + delete stari; + } + prvi = posl = nullptr; + } + void premesti(lista &l1) { + prvi = l1.prvi; + posl = l1.posl; + l1.prvi = nullptr; + l1.posl = nullptr; + } + void kopiraj(lista &l) { + elem*tek = l.prvi; + elem*novi = nullptr; + while (tek) { + novi = new elem(tek->pok); + if (prvi == nullptr) { + prvi = posl = novi; + } + posl->next = novi; + posl = posl->next; + tek = tek->next; + } + + } + void pisi(ostream&it) { + elem * tek = prvi; + it << "["; + while (tek) { + if (tek != prvi) { + cout << " | "; + } + it << *tek->pok; + tek = tek->next; + } + it << "]" << endl; + } +public: + lista(elem *f = nullptr, elem * l = nullptr) { + prvi = f; + posl = l; + } + lista& operator=(lista& l1) { + if (this != &l1) { + brisi(); + kopiraj(l1); + } + return*this; + } + friend ostream&operator<<(ostream&it, const kvadar&k) { + k.pisi(it); + return it; + } +}; \ No newline at end of file diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/kvadar lista-novi standard-druga verzija/Project2/Debug/Project2.log b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/kvadar lista-novi standard-druga verzija/Project2/Debug/Project2.log new file mode 100644 index 0000000..5f28270 --- /dev/null +++ b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/kvadar lista-novi standard-druga verzija/Project2/Debug/Project2.log @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/kvadar lista-novi standard-druga verzija/Project2/Debug/Project2.tlog/Project2.lastbuildstate b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/kvadar lista-novi standard-druga verzija/Project2/Debug/Project2.tlog/Project2.lastbuildstate new file mode 100644 index 0000000..1900421 --- /dev/null +++ b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/kvadar lista-novi standard-druga verzija/Project2/Debug/Project2.tlog/Project2.lastbuildstate @@ -0,0 +1,2 @@ +#TargetFrameworkVersion=v4.0:PlatformToolSet=v141:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=10.0.14393.0 +Debug|Win32|c:\users\djdjm\documents\visual studio 2017\Projects\Project2\| diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/kvadar lista-novi standard-druga verzija/Project2/Project2.vcxproj b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/kvadar lista-novi standard-druga verzija/Project2/Project2.vcxproj new file mode 100644 index 0000000..400dba2 --- /dev/null +++ b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/kvadar lista-novi standard-druga verzija/Project2/Project2.vcxproj @@ -0,0 +1,120 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 15.0 + {AF5B1A12-3381-40B2-BB52-9E4C02BC6BFE} + Project2 + 10.0.14393.0 + + + + Application + true + v141 + MultiByte + + + Application + false + v141 + true + MultiByte + + + Application + true + v141 + MultiByte + + + Application + false + v141 + true + MultiByte + + + + + + + + + + + + + + + + + + + + + + + Level3 + Disabled + true + + + + + Level3 + Disabled + true + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + + + + + + + + + + \ No newline at end of file diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/kvadar lista-novi standard-druga verzija/Project2/Project2.vcxproj.filters b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/kvadar lista-novi standard-druga verzija/Project2/Project2.vcxproj.filters new file mode 100644 index 0000000..7b9e245 --- /dev/null +++ b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/kvadar lista-novi standard-druga verzija/Project2/Project2.vcxproj.filters @@ -0,0 +1,25 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + Header Files + + + \ No newline at end of file diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/kvadar lista-novi standard/zad2/Lista.h b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/kvadar lista-novi standard/zad2/Lista.h new file mode 100644 index 0000000..c36baba --- /dev/null +++ b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/kvadar lista-novi standard/zad2/Lista.h @@ -0,0 +1,90 @@ +#ifndef _Lista_h_ +#define _Lista_h_ + +#include "kvadar.h" + +class Lista{ +private: + void brisi(){ + while (prvi){ + Elem *stari=prvi; + prvi=prvi->sled; + delete stari; + } + } + + void kopiraj(const Lista &l1){ + prvi=posl=0; + for (Elem *tek=l1.prvi;tek;tek=tek->sled){ + *this+=tek->kv; + } + } + + void premesti(Lista &l1) { + prvi = l1.prvi; + posl = l1.posl; + l1.prvi = nullptr; + l1.posl = nullptr; + } +protected: + struct Elem{ + Kvadar kv; + Elem* sled; + explicit Elem(const Kvadar &k1, Elem *sl = nullptr) : kv(k1) { sled = sl; } + }; + + Elem *prvi,*posl; + + virtual void pisi(ostream &it) const { + it << "["; + for (Elem *tek = prvi; tek; tek = tek->sled){ + if (tek == prvi) it << tek->kv; + else it << "|" << tek->kv; + it << "]"; + } + } +public: + Lista() { prvi=posl=nullptr; } + + virtual ~Lista() { brisi(); } + + Lista(const Lista &l1) { kopiraj(l1); } + + Lista(Lista &&l1) { premesti(l1); } + + Lista &operator=(const Lista &l1){ + if (this!=&l1){ + brisi(); + kopiraj(l1); + } + return *this; + } + + Lista &operator=(Lista &&l1){ + if (this != &l1){ + brisi(); + premesti(l1); + } + return *this; + } + + virtual Lista *kopija() const { return new Lista(*this); } + + virtual Lista& operator+=(const Kvadar& kv){ + Elem *novi=new Elem(kv); + if (prvi==nullptr) + prvi=posl=novi; + else { + posl->sled=novi; + posl=novi; + } + return *this; + } + + friend ostream& operator<<(ostream& it, const Lista& l){ + l.pisi(it); + return it; + } +}; + +#endif \ No newline at end of file diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/kvadar lista-novi standard/zad2/Skup.h b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/kvadar lista-novi standard/zad2/Skup.h new file mode 100644 index 0000000..9ccd03a --- /dev/null +++ b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/kvadar lista-novi standard/zad2/Skup.h @@ -0,0 +1,23 @@ +#ifndef _skup_h_ +#define _skup_h_ + +#include "Lista.h" + +class Skup: public Lista{ +public: + Skup(): Lista() {} + + Skup *kopija() const override { return new Skup(*this); } + + Skup& operator+=(const Kvadar& kv) override { + for (Elem* tek = prvi; tek; tek=tek->sled){ + if (tek->kv == kv) return *this; + } + Lista::operator+=(kv); + return *this; + } + +}; + +#endif + diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/kvadar lista-novi standard/zad2/kvadar.h b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/kvadar lista-novi standard/zad2/kvadar.h new file mode 100644 index 0000000..2ad5d16 --- /dev/null +++ b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/kvadar lista-novi standard/zad2/kvadar.h @@ -0,0 +1,28 @@ +#ifndef _kvadar_h_ +#define _kvadar_h_ + +#include +using namespace std; + +class Kvadar { +private: + double a,b,c; +public: + explicit Kvadar(double prva=1,double druga=1,double treca=1) { + a=prva; b=druga;c=treca; + } + + double zapremina() const { return a*b*c; } + + friend bool operator==(const Kvadar &prvi, const Kvadar &drugi){ + return prvi.a==drugi.a && prvi.b==drugi.b && prvi.c==drugi.c; + } + + friend ostream& operator<<(ostream &it, const Kvadar &k){ + it<<"K("< + +void main(){ + int izbor; + do { + Lista lis; + Skup sk; + + while (true) { + int a,b,c; + cout<<"Unesi dimenzije sledeceg kvadra:"<>a>>b>>c; + if (a < 0 || b < 0 || c < 0) break; + Kvadar k(a,b,c); + lis += k; + sk += k; + } + + cout<> izbor; + } while (izbor != 0); +} \ No newline at end of file diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/kvadar lista-novi standard/zad2/metode2.cpp b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/kvadar lista-novi standard/zad2/metode2.cpp new file mode 100644 index 0000000..60a4c86 --- /dev/null +++ b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/kvadar lista-novi standard/zad2/metode2.cpp @@ -0,0 +1 @@ +//izdvoj duze metode u ovaj fajl \ No newline at end of file diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/kvadar lista-novi standard/zad2/zad2.vcxproj b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/kvadar lista-novi standard/zad2/zad2.vcxproj new file mode 100644 index 0000000..80fc408 --- /dev/null +++ b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/kvadar lista-novi standard/zad2/zad2.vcxproj @@ -0,0 +1,90 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {244F9EC2-EC58-4D14-9720-95ABEDE56750} + Win32Proj + zad2 + + + + Application + true + v120 + Unicode + + + Application + false + v120 + true + Unicode + + + + + + + + + + + + + true + + + false + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) + + + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) + + + Console + true + true + true + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/kvadar lista-novi standard/zad2/zad2.vcxproj.filters b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/kvadar lista-novi standard/zad2/zad2.vcxproj.filters new file mode 100644 index 0000000..c4eea06 --- /dev/null +++ b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/kvadar lista-novi standard/zad2/zad2.vcxproj.filters @@ -0,0 +1,36 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Header Files + + + Header Files + + + Header Files + + + + + Source Files + + + Source Files + + + \ No newline at end of file diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/merna tacka-novi standard/zad 4/main4.cpp b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/merna tacka-novi standard/zad 4/main4.cpp new file mode 100644 index 0000000..b71d193 --- /dev/null +++ b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/merna tacka-novi standard/zad 4/main4.cpp @@ -0,0 +1,28 @@ +#include "tacka.h" +#include "merenje.h" +#include "mernatacka.h" +#include "zbirkamt.h" + +#include +using namespace std; + +int main() { + ZbirkaMT zmt(3); + + MernaTacka mt(2); + + mt += Merenje(20, 5000); + mt += Merenje(30, 7000); + + zmt += mt; + + mt = MernaTacka(3); + mt += Merenje(40, 6000); + mt += Merenje(50, 5000); + mt += Merenje(20, 7000); + + zmt += mt; + + cout << "Srednja: " << zmt(4500,6500) << endl; + return 0; +} \ No newline at end of file diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/merna tacka-novi standard/zad 4/merenje.h b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/merna tacka-novi standard/zad 4/merenje.h new file mode 100644 index 0000000..69d1038 --- /dev/null +++ b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/merna tacka-novi standard/zad 4/merenje.h @@ -0,0 +1,21 @@ +#ifndef MERENJE +#define MERENJE + +#include +using namespace std; + +class Merenje { +protected: + double temp; + long vreme; +public: + Merenje(double ttemp, long vvreme) { + temp = ttemp; + vreme = vvreme; + } + + double getTemp() const { return temp; } + long getVreme() const { return vreme; } +}; + +#endif \ No newline at end of file diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/merna tacka-novi standard/zad 4/mernatacka.h b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/merna tacka-novi standard/zad 4/mernatacka.h new file mode 100644 index 0000000..00ad830 --- /dev/null +++ b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/merna tacka-novi standard/zad 4/mernatacka.h @@ -0,0 +1,95 @@ +#ifndef MERNATACKA +#define MERNATACKA + +#include "tacka.h" +#include "merenje.h" + +#include +#include +using namespace std; + +class MernaTacka : public Tacka { +protected: + Merenje **pniz; + int kap, pop; + + void brisi() { + if (pniz == nullptr) return; + for (int i=0; i pop-1) exit(23); + return *pniz[indeks]; + } + + const Merenje &operator[](int indeks) const { //pristup merenju za konstantan objekat + if (indeks < 0 || indeks > pop - 1) exit(23); + return *pniz[indeks]; + } + + double operator()(long t1, long t2) const { + double suma = 0; + int n = 0; + for (int i=0; igetVreme() > t1 && pniz[i]->getVreme() < t2) { + suma += pniz[i]->getTemp(); + n++; + } + if (n==0) return 0; + else return suma/n; + } +}; + +#endif \ No newline at end of file diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/merna tacka-novi standard/zad 4/metode4.cpp b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/merna tacka-novi standard/zad 4/metode4.cpp new file mode 100644 index 0000000..60a4c86 --- /dev/null +++ b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/merna tacka-novi standard/zad 4/metode4.cpp @@ -0,0 +1 @@ +//izdvoj duze metode u ovaj fajl \ No newline at end of file diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/merna tacka-novi standard/zad 4/tacka.h b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/merna tacka-novi standard/zad 4/tacka.h new file mode 100644 index 0000000..f06ddda --- /dev/null +++ b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/merna tacka-novi standard/zad 4/tacka.h @@ -0,0 +1,32 @@ +#ifndef TACKA +#define TACKA + +#include +#include +using namespace std; + +class Tacka { +protected: + double x, y, z; + + virtual void pisi(ostream &it) const { it << "(" << x << "," << y << "," << z << ")"; } +public: + explicit Tacka(double xx=0, double yy=0, double zz=0) { + x = xx; y = yy; z = zz; + } + + virtual ~Tacka() {} + + virtual Tacka *kopija() const { return new Tacka(*this); } + + friend double operator-(const Tacka &t1, const Tacka &t2) { + return sqrt(pow(t1.x-t2.x, 2) + pow(t1.y-t2.y, 2) + pow(t1.z-t2.z, 2)); + } + + friend ostream &operator<<(ostream &it, const Tacka &t) { + t.pisi(it); + return it; + } +}; + +#endif \ No newline at end of file diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/merna tacka-novi standard/zad 4/zad 4.vcxproj b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/merna tacka-novi standard/zad 4/zad 4.vcxproj new file mode 100644 index 0000000..93dbcc9 --- /dev/null +++ b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/merna tacka-novi standard/zad 4/zad 4.vcxproj @@ -0,0 +1,91 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + + + + + + + + + + + {689D8701-9BAB-4C50-8263-2B03827E6FD6} + Win32Proj + zad4 + + + + Application + true + v120 + Unicode + + + Application + false + v120 + true + Unicode + + + + + + + + + + + + + true + + + false + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) + + + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) + + + Console + true + true + true + + + + + + \ No newline at end of file diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/merna tacka-novi standard/zad 4/zad 4.vcxproj.filters b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/merna tacka-novi standard/zad 4/zad 4.vcxproj.filters new file mode 100644 index 0000000..232a483 --- /dev/null +++ b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/merna tacka-novi standard/zad 4/zad 4.vcxproj.filters @@ -0,0 +1,39 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + \ No newline at end of file diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/merna tacka-novi standard/zad 4/zbirkamt.h b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/merna tacka-novi standard/zad 4/zbirkamt.h new file mode 100644 index 0000000..c272e18 --- /dev/null +++ b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/merna tacka-novi standard/zad 4/zbirkamt.h @@ -0,0 +1,82 @@ +#ifndef ZBIRKAMT +#define ZBIRKAMT + +#include "mernatacka.h" + +#include +#include +using namespace std; + +class ZbirkaMT { + MernaTacka **pniz; + int kap, pop; + + void brisi() { + if (pniz == nullptr) return; + for (int i=0; ioperator()(t1, t2); //suma += (*this)(t1, t2); + + if (pop==0) return 0; + else return suma/pop; + } +}; + +#endif \ No newline at end of file diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/otpornik-novi standard/zad 2/main3.cpp b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/otpornik-novi standard/zad 2/main3.cpp new file mode 100644 index 0000000..03772bb --- /dev/null +++ b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/otpornik-novi standard/zad 2/main3.cpp @@ -0,0 +1,23 @@ +#include "otpornik.h" +#include "prost.h" +#include "slozen.h" +#include "redna.h" + +int main() { + Redna red1(3); + + red1 += Prost(5.5); + red1 += Prost(4.4); + red1 += Prost(9); + + Redna veza(4); + + veza += red1; + veza += Prost(4.3); + veza += Prost(1.1); + veza += red1; + + cout << veza << endl << endl; + + return 0; +} \ No newline at end of file diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/otpornik-novi standard/zad 2/metode3.cpp b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/otpornik-novi standard/zad 2/metode3.cpp new file mode 100644 index 0000000..77dea8e --- /dev/null +++ b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/otpornik-novi standard/zad 2/metode3.cpp @@ -0,0 +1,36 @@ +#include "otpornik.h" +#include "prost.h" +#include "slozen.h" +#include "redna.h" + +double Redna::otpornost() const { + double suma = 0; + for (int i = 0; iotpornost(); + return suma; +} + +void Slozen::brisi() { + if (pniz == nullptr) return; + + for (int i = 0; ikopija(); //zove polimorfno kopiranje objekta +} + +void Slozen::pisi(ostream &it) const { + it << "("; + for (int i = 0; i +using namespace std; + +class Otpornik { +protected: //stavili smo u protected da bi videle izvedene klase + virtual void pisi(ostream &it) const = 0; +public: + Otpornik() {} //nije moralo da se pise + + virtual ~Otpornik() {} //uvek u osnovnoj klasi ostavi virtuelan prazan destruktor + + virtual double otpornost() const = 0; //metoda je apstraktna, mora da se definise u izvedenoj klasi + + virtual Otpornik *kopija() const = 0; + + //funkcija ne moze da bude polimorfna (ili apstraktna), to moze samo metoda + //da bismo ostvarili polimorfizam, f-ja zove polimorfnu metodu za pisanje + friend ostream &operator<<(ostream &it, const Otpornik &o) { + o.pisi(it); + return it; + } +}; + +#endif \ No newline at end of file diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/otpornik-novi standard/zad 2/prost.h b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/otpornik-novi standard/zad 2/prost.h new file mode 100644 index 0000000..9e71d3a --- /dev/null +++ b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/otpornik-novi standard/zad 2/prost.h @@ -0,0 +1,20 @@ +#ifndef _PROST_H_ +#define _PROST_H_ + +#include "otpornik.h" + +//klasa Prost se javno izvodi iz klase Otpornik +class Prost : public Otpornik { +protected: + double R; + + void pisi(ostream &it) const override { it << R; } +public: + explicit Prost(double RR=1) : Otpornik() { R = RR; } + + double otpornost() const override { return R; } + + Prost *kopija() const override { return new Prost(*this); } +}; + +#endif \ No newline at end of file diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/otpornik-novi standard/zad 2/redna.h b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/otpornik-novi standard/zad 2/redna.h new file mode 100644 index 0000000..b822f75 --- /dev/null +++ b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/otpornik-novi standard/zad 2/redna.h @@ -0,0 +1,29 @@ +#ifndef _REDNA_H_ +#define _REDNA_H_ + +#include "slozen.h" + +/*Redosled pozivanja konstruktora: +1.konstruktor osnovne klase +2.konstruktori atributa klasnog tipa, redosledom navodjenja +3.konstruktor izvedene klase + +Destruktori se pozivaju obrnutim redosledom. +*/ + +class Redna : public Slozen { +protected: + void pisi(ostream &it) const override { + it << "red"; + Slozen::pisi(it); //poziv metode pisi od osnovne klase, preko :: (pripadnosti) + } +public: + //posto slozen ima konstruktor, i redna mora da ima konstruktor + explicit Redna(int kap=10) : Slozen(kap) {} + + double otpornost() const override; + + Redna *kopija() const override { return new Redna(*this); } +}; + +#endif \ No newline at end of file diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/otpornik-novi standard/zad 2/slozen.h b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/otpornik-novi standard/zad 2/slozen.h new file mode 100644 index 0000000..1c3732b --- /dev/null +++ b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/otpornik-novi standard/zad 2/slozen.h @@ -0,0 +1,62 @@ +#ifndef _SLOZEN_H_ +#define _SLOZEN_H_ + +#include "otpornik.h" + +class Slozen : public Otpornik { +private: + void brisi(); + + void kopiraj(const Slozen &s); + + void premesti(Slozen &s) { + kap = s.kap; + pop = s.pop; + pniz = s.pniz; + s.pniz = nullptr; + } +protected: + Otpornik **pniz; + int kap, pop; + + virtual void pisi(ostream &it) const override; +public: + explicit Slozen(int kkap=10) { + kap = kkap; + pop = 0; + pniz = new Otpornik *[kap]; + } + + Slozen(const Slozen &s) { kopiraj(s); } + + Slozen(Slozen &&s) { premesti(s); } + + //posto je ovo klasa iz koje se dalje izvodi, ostavljam virtual destruktor + virtual ~Slozen() override { brisi(); } + + Slozen &operator=(const Slozen &s) { + if (this != &s) { + brisi(); + kopiraj(s); + } + return *this; + } + + Slozen &operator=(Slozen &&s) { + if (this != &s) { + brisi(); + premesti(s); + } + return *this; + } + + bool operator+=(const Otpornik &o) { + if (kap == pop) return false; + pniz[pop++] = o.kopija(); //polimorfno kopiranje + return true; + } + + //nismo redefinisali otpornost() i kopija(), pa ova klasa ostaje apstraktna +}; + +#endif \ No newline at end of file diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/otpornik-novi standard/zad 2/zad 2.vcxproj b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/otpornik-novi standard/zad 2/zad 2.vcxproj new file mode 100644 index 0000000..a43e3aa --- /dev/null +++ b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/otpornik-novi standard/zad 2/zad 2.vcxproj @@ -0,0 +1,92 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {3BA4695F-9463-414D-9264-14ECDD440113} + Win32Proj + zad2 + zad 3 + + + + Application + true + v120 + Unicode + + + Application + false + v120 + true + Unicode + + + + + + + + + + + + + true + + + false + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) + + + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) + + + Console + true + true + true + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/otpornik-novi standard/zad 2/zad 2.vcxproj.filters b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/otpornik-novi standard/zad 2/zad 2.vcxproj.filters new file mode 100644 index 0000000..9370a37 --- /dev/null +++ b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/otpornik-novi standard/zad 2/zad 2.vcxproj.filters @@ -0,0 +1,39 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Source Files + + + Source Files + + + \ No newline at end of file diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard-druga verzija/Debug/Project1.exe b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard-druga verzija/Debug/Project1.exe new file mode 100644 index 0000000..1b96a23 Binary files /dev/null and b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard-druga verzija/Debug/Project1.exe differ diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard-druga verzija/Debug/Project1.ilk b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard-druga verzija/Debug/Project1.ilk new file mode 100644 index 0000000..d35c6b3 Binary files /dev/null and b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard-druga verzija/Debug/Project1.ilk differ diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard-druga verzija/Debug/Project1.pdb b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard-druga verzija/Debug/Project1.pdb new file mode 100644 index 0000000..7dcd289 Binary files /dev/null and b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard-druga verzija/Debug/Project1.pdb differ diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard-druga verzija/Project1.sln b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard-druga verzija/Project1.sln new file mode 100644 index 0000000..ab0f16d --- /dev/null +++ b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard-druga verzija/Project1.sln @@ -0,0 +1,28 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26228.12 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Project1", "Project1\Project1.vcxproj", "{D4D5D2F5-87F7-4786-8E70-98666D4A6608}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D4D5D2F5-87F7-4786-8E70-98666D4A6608}.Debug|x64.ActiveCfg = Debug|x64 + {D4D5D2F5-87F7-4786-8E70-98666D4A6608}.Debug|x64.Build.0 = Debug|x64 + {D4D5D2F5-87F7-4786-8E70-98666D4A6608}.Debug|x86.ActiveCfg = Debug|Win32 + {D4D5D2F5-87F7-4786-8E70-98666D4A6608}.Debug|x86.Build.0 = Debug|Win32 + {D4D5D2F5-87F7-4786-8E70-98666D4A6608}.Release|x64.ActiveCfg = Release|x64 + {D4D5D2F5-87F7-4786-8E70-98666D4A6608}.Release|x64.Build.0 = Release|x64 + {D4D5D2F5-87F7-4786-8E70-98666D4A6608}.Release|x86.ActiveCfg = Release|Win32 + {D4D5D2F5-87F7-4786-8E70-98666D4A6608}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard-druga verzija/Project1/20161mnogougal.cpp b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard-druga verzija/Project1/20161mnogougal.cpp new file mode 100644 index 0000000..5cfe155 --- /dev/null +++ b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard-druga verzija/Project1/20161mnogougal.cpp @@ -0,0 +1,29 @@ +#include "20161mnogougal.h" + +void mnogougal::brisi() +{ + for (int i = 0; i < pop; i++) { + delete niz[i]; + niz[i] = nullptr; + } + delete[] niz; + pop = 0; +} + +void mnogougal::kopiraj(const mnogougal & m) +{ + pop = m.pop; + kap = m.kap; + niz = new tacka*[m.kap]; + for (int i = 0; i < m.pop; i++) { + niz[i] = m.niz[i]->klon(); + } +} + +void mnogougal::premesti(mnogougal & m) +{ + pop = m.pop; + kap = m.kap; + niz = m.niz; + m.niz = nullptr; +} diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard-druga verzija/Project1/20161mnogougal.h b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard-druga verzija/Project1/20161mnogougal.h new file mode 100644 index 0000000..3365461 --- /dev/null +++ b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard-druga verzija/Project1/20161mnogougal.h @@ -0,0 +1,53 @@ +#pragma once +#include "20161tacka.h" +#include "20161napuderisanaTacka.h" +#include +#include +#include +using namespace std; +class mnogougal { +private: + void brisi(); + void kopiraj(const mnogougal& m); + tacka ** niz; + int kap; + int pop; + void premesti(mnogougal& m); +public: + ~mnogougal() { brisi(); } + mnogougal(const mnogougal &m) { kopiraj(m); } + mnogougal(mnogougal &&m) { premesti(m); } + explicit mnogougal(int kkap = 3) : kap(kkap) { + niz = new tacka*[kkap]; + pop = 0; + for (int i = 0; i < kkap; i++) { niz[i] = nullptr; } + } + void operator+= (tacka& t1) + { + if (pop == kap) exit(1); + niz[pop++] = t1.klon(); + } + mnogougal& operator= (const mnogougal& m1) { + if (this != &m1) { + brisi(); + kopiraj(m1); + } + return *this; + } + mnogougal& operator= (mnogougal&& m1) { + if (this != &m1) { + brisi(); + premesti(m1); + } + return *this; + } + friend ostream& operator<<(ostream&it, const mnogougal& m) { + it << "[ "; + for (int i = 0; i < m.pop; i++) { + if (i != 0) it << "|"; + cout << *m.niz[i]; + } + it << " ]" << endl; + return it; + } +}; \ No newline at end of file diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard-druga verzija/Project1/20161napuderisanaTacka.h b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard-druga verzija/Project1/20161napuderisanaTacka.h new file mode 100644 index 0000000..af69729 --- /dev/null +++ b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard-druga verzija/Project1/20161napuderisanaTacka.h @@ -0,0 +1,22 @@ +#pragma once +#include "20161tacka.h" +#include +#include +#include +using namespace std; +class napuderisana : public tacka { +protected: + int q; + virtual void pisi(ostream& it) { + tacka::pisi(it); + it << " * " << q; + } +public: + napuderisana(int xx, int yy, int zz, int qq) : tacka(xx, yy, zz), q(qq){} + double rastojanje() override { + double pera = tacka::rastojanje(); + pera = pera * q; + return pera; + } + virtual napuderisana* klon() { return new napuderisana(*this); } +}; \ No newline at end of file diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard-druga verzija/Project1/20161tacka.h b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard-druga verzija/Project1/20161tacka.h new file mode 100644 index 0000000..df711d9 --- /dev/null +++ b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard-druga verzija/Project1/20161tacka.h @@ -0,0 +1,25 @@ +#pragma once +#include +#include +#include +using namespace std; +class tacka { +protected: + virtual void pisi(ostream&it) { + it << "( " << x << ", " << y << ", " << z << " )"; + } + int x; + int y; + int z; +public: + tacka(int a = 0, int b = 0, int c = 0) :x(a), y(b), z(c){} + virtual double rastojanje() { + return sqrt(x*x + y*y + z*z); + } + virtual tacka* klon() { return new tacka(*this); } + friend ostream& operator<<(ostream&it, tacka& t) { + t.pisi(it); + return it; + } + virtual ~tacka(){} +}; \ No newline at end of file diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard-druga verzija/Project1/Debug/20161mnogougal.obj b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard-druga verzija/Project1/Debug/20161mnogougal.obj new file mode 100644 index 0000000..db55074 Binary files /dev/null and b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard-druga verzija/Project1/Debug/20161mnogougal.obj differ diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard-druga verzija/Project1/Debug/Project1.log b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard-druga verzija/Project1/Debug/Project1.log new file mode 100644 index 0000000..4deaa4c --- /dev/null +++ b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard-druga verzija/Project1/Debug/Project1.log @@ -0,0 +1,7 @@ + 20161mnogougal.cpp + Generating Code... + Compiling... + main.cpp + Generating Code... + Project1.vcxproj -> c:\users\djdjm\documents\visual studio 2017\Projects\Project1\Debug\Project1.exe + Project1.vcxproj -> c:\users\djdjm\documents\visual studio 2017\Projects\Project1\Debug\Project1.pdb (Partial PDB) diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard-druga verzija/Project1/Debug/Project1.tlog/CL.command.1.tlog b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard-druga verzija/Project1/Debug/Project1.tlog/CL.command.1.tlog new file mode 100644 index 0000000..a0e8677 Binary files /dev/null and b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard-druga verzija/Project1/Debug/Project1.tlog/CL.command.1.tlog differ diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard-druga verzija/Project1/Debug/Project1.tlog/CL.read.1.tlog b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard-druga verzija/Project1/Debug/Project1.tlog/CL.read.1.tlog new file mode 100644 index 0000000..b84192d Binary files /dev/null and b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard-druga verzija/Project1/Debug/Project1.tlog/CL.read.1.tlog differ diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard-druga verzija/Project1/Debug/Project1.tlog/CL.write.1.tlog b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard-druga verzija/Project1/Debug/Project1.tlog/CL.write.1.tlog new file mode 100644 index 0000000..84078bd Binary files /dev/null and b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard-druga verzija/Project1/Debug/Project1.tlog/CL.write.1.tlog differ diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard-druga verzija/Project1/Debug/Project1.tlog/Project1.lastbuildstate b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard-druga verzija/Project1/Debug/Project1.tlog/Project1.lastbuildstate new file mode 100644 index 0000000..165a2c1 --- /dev/null +++ b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard-druga verzija/Project1/Debug/Project1.tlog/Project1.lastbuildstate @@ -0,0 +1,2 @@ +#TargetFrameworkVersion=v4.0:PlatformToolSet=v141:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=10.0.14393.0 +Debug|Win32|c:\users\djdjm\documents\visual studio 2017\Projects\Project1\| diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard-druga verzija/Project1/Debug/Project1.tlog/link.command.1.tlog b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard-druga verzija/Project1/Debug/Project1.tlog/link.command.1.tlog new file mode 100644 index 0000000..91ec657 Binary files /dev/null and b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard-druga verzija/Project1/Debug/Project1.tlog/link.command.1.tlog differ diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard-druga verzija/Project1/Debug/Project1.tlog/link.read.1.tlog b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard-druga verzija/Project1/Debug/Project1.tlog/link.read.1.tlog new file mode 100644 index 0000000..7828fc7 Binary files /dev/null and b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard-druga verzija/Project1/Debug/Project1.tlog/link.read.1.tlog differ diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard-druga verzija/Project1/Debug/Project1.tlog/link.write.1.tlog b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard-druga verzija/Project1/Debug/Project1.tlog/link.write.1.tlog new file mode 100644 index 0000000..78a3f33 Binary files /dev/null and b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard-druga verzija/Project1/Debug/Project1.tlog/link.write.1.tlog differ diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard-druga verzija/Project1/Debug/main.obj b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard-druga verzija/Project1/Debug/main.obj new file mode 100644 index 0000000..9a83108 Binary files /dev/null and b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard-druga verzija/Project1/Debug/main.obj differ diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard-druga verzija/Project1/Debug/vc141.idb b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard-druga verzija/Project1/Debug/vc141.idb new file mode 100644 index 0000000..1a4ee6c Binary files /dev/null and b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard-druga verzija/Project1/Debug/vc141.idb differ diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard-druga verzija/Project1/Debug/vc141.pdb b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard-druga verzija/Project1/Debug/vc141.pdb new file mode 100644 index 0000000..410bda9 Binary files /dev/null and b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard-druga verzija/Project1/Debug/vc141.pdb differ diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard-druga verzija/Project1/Project1.vcxproj b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard-druga verzija/Project1/Project1.vcxproj new file mode 100644 index 0000000..fcfe810 --- /dev/null +++ b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard-druga verzija/Project1/Project1.vcxproj @@ -0,0 +1,125 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 15.0 + {D4D5D2F5-87F7-4786-8E70-98666D4A6608} + Project1 + 10.0.14393.0 + + + + Application + true + v141 + MultiByte + + + Application + false + v141 + true + MultiByte + + + Application + true + v141 + MultiByte + + + Application + false + v141 + true + MultiByte + + + + + + + + + + + + + + + + + + + + + + + Level3 + Disabled + true + + + + + Level3 + Disabled + true + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard-druga verzija/Project1/Project1.vcxproj.filters b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard-druga verzija/Project1/Project1.vcxproj.filters new file mode 100644 index 0000000..4538a97 --- /dev/null +++ b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard-druga verzija/Project1/Project1.vcxproj.filters @@ -0,0 +1,36 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + Source Files + + + Source Files + + + + + Source Files + + + Source Files + + + \ No newline at end of file diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard-druga verzija/Project1/main.cpp b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard-druga verzija/Project1/main.cpp new file mode 100644 index 0000000..92b9d71 --- /dev/null +++ b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard-druga verzija/Project1/main.cpp @@ -0,0 +1,29 @@ +#include "20161tacka.h" +#include "20161napuderisanaTacka.h" +#include +#include +#include +#include "20161mnogougal.h" +using namespace std; +int main() { + int kapp; + int a, b, c, t, q; + cout << "kap?" << endl; + cin >> kapp; + mnogougal mn(kapp); + for (int i = 0; i < kapp; i++) { + cout << "tacka = 1, napuderisana = 0?" << endl; + cin >> t; + cout << "kooredinate" << endl; + cin >> a >> b >> c; + if (t == 0) { + cout << "koef?" << endl; + cin >> q; + mn += napuderisana(a, b, c, q); + } + else { + mn += tacka(a, b, c); + } + } + cout << mn; +} \ No newline at end of file diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard/zad 1/main1.cpp b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard/zad 1/main1.cpp new file mode 100644 index 0000000..fd7c21d --- /dev/null +++ b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard/zad 1/main1.cpp @@ -0,0 +1,36 @@ +#include "tacka.h" +#include "ptacka.h" +#include "mnogougao.h" + +#include +using namespace std; + +void main() { + while (true) { + int n, izbor; + cin >> n; + if (n<=0) break; + Mnogougao mn(n); + + Tacka *tp; + + double x,y,z,q; + for (int i=0; i> izbor; + + cout << "x,y,z?"; + cin >> x >> y >> z; + if (izbor == 2) { + cout << "q?"; + cin >> q; + mn += PTacka(x,y,z,q); + } else + mn += Tacka(x,y,z); + } + + cout << mn; + + cout << *mn.najbliza() << endl; + } +} \ No newline at end of file diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard/zad 1/metode1.cpp b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard/zad 1/metode1.cpp new file mode 100644 index 0000000..76e0573 --- /dev/null +++ b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard/zad 1/metode1.cpp @@ -0,0 +1,36 @@ +#include "mnogougao.h" +#include "ptacka.h" +#include "tacka.h" + +void Mnogougao::brisi() { + if (pniz == nullptr) return; + for (int i = 0; i < pop; i++) + delete pniz[i]; + delete[] pniz; +} + +void Mnogougao::kopiraj(const Mnogougao &m) { + kap = m.kap; + pop = m.pop; + pniz = new Tacka *[kap]; + for (int i = 0; i < pop; i++) + pniz[i] = m.pniz[i]->kopija(); +} + +const Tacka *Mnogougao::najbliza() const { + if (pop == 0) return nullptr; //ako nema nijedne tacke dodate, vracamo nula + Tacka *min = pniz[0]; + for (int i = 0; iudaljenost() < min->udaljenost()) min = pniz[i]; + return min; +} + +ostream &operator<<(ostream &it, const Mnogougao &m) { + it << "["; + for (int i = 0; i +#include +using namespace std; + +class Mnogougao { + Tacka **pniz; + int kap, pop; + + void brisi(); + + void kopiraj(const Mnogougao &m); + + void premesti(Mnogougao &m) { + kap = m.kap; + pop = m.pop; + pniz = m.pniz; + m.pniz = nullptr; + } +public: + explicit Mnogougao(int kkap=3) { + kap = kkap; + pop = 0; + pniz = new Tacka *[kap]; + } + + ~Mnogougao() { brisi(); } + Mnogougao(const Mnogougao &m) { kopiraj(m); } + Mnogougao(Mnogougao &&m) { premesti(m); } + Mnogougao &operator=(const Mnogougao &m) { + if (this != &m) { + brisi(); + kopiraj(m); + } + return *this; + } + Mnogougao &operator=(Mnogougao &&m) { + if (this != &m) { + brisi(); + premesti(m); + } + return *this; + } + + //m+=pt -> m.operator+=(pt) + Mnogougao &operator+=(const Tacka &pt) { + if (kap == pop) exit(-1); + + pniz[pop++] = pt.kopija(); //dohvatam dinamicku kopiju poslate tacke + return *this; + } + + /*// m+=pt -> operator+=(m,pt) + friend Mnogougao &operator+=(Mnogougao &m, const Tacka &pt) { + if (m.kap == m.pop) exit(-1); + m.pniz[m.pop++] = pt.kopija(); + return m; + }*/ + + int brojTemena() const { return pop; } + + const Tacka *najbliza() const; + + friend ostream &operator<<(ostream &it, const Mnogougao &m); +}; + +#endif diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard/zad 1/ptacka.h b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard/zad 1/ptacka.h new file mode 100644 index 0000000..b516c21 --- /dev/null +++ b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard/zad 1/ptacka.h @@ -0,0 +1,25 @@ +#ifndef PTACKA +#define PTACKA + +#include "tacka.h" +#include +using namespace std; + +class PTacka : public Tacka { +protected: + double q; + + void pisi(ostream &it) const override { + Tacka::pisi(it); //prvo zovem pisi od roditelja + it << "*" << q; + } +public: + //prvo se poziva konstruktor osnovne klase, pa konstruktori atributa klasnog tipa, pa konstruktor izvedene klase + explicit PTacka(double xx=0, double yy=0, double zz=0, double qq=1) : Tacka(xx, yy, zz) { q = qq; } + + double udaljenost() const override { return Tacka::udaljenost()*q; } + + PTacka *kopija() const override { return new PTacka(*this); } +}; + +#endif \ No newline at end of file diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard/zad 1/tacka.h b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard/zad 1/tacka.h new file mode 100644 index 0000000..cb8713d --- /dev/null +++ b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard/zad 1/tacka.h @@ -0,0 +1,37 @@ +#ifndef TACKA +#define TACKA + +#include +#include +using namespace std; + +class Tacka { +protected: + double x, y, z; + + //polimorfno pisanje + virtual void pisi(ostream &it) const { + it << "(" << x << "," << y << "," << z << ")"; + } +public: + explicit Tacka(double xx=0, double yy=0, double zz=0) { + x = xx; y = yy; z = zz; + } + + //uvek se u osnovnu klasu stavlja virtuelni destruktor + virtual ~Tacka() {} + + //trazio je polimorfno kopiranje + virtual Tacka *kopija() const { return new Tacka(*this); } + + virtual double udaljenost() const { + return sqrt(x*x+y*y+z*z); + } + + friend ostream &operator<<(ostream &it, const Tacka &t) { + t.pisi(it); + return it; + } +}; + +#endif \ No newline at end of file diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard/zad 1/zad 1.vcxproj b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard/zad 1/zad 1.vcxproj new file mode 100644 index 0000000..b043dd6 --- /dev/null +++ b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard/zad 1/zad 1.vcxproj @@ -0,0 +1,90 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {C2B35B38-50ED-4AC3-ABB3-74C700D99255} + Win32Proj + zad1 + + + + Application + true + v120 + Unicode + + + Application + false + v120 + true + Unicode + + + + + + + + + + + + + true + + + false + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) + + + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) + + + Console + true + true + true + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard/zad 1/zad 1.vcxproj.filters b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard/zad 1/zad 1.vcxproj.filters new file mode 100644 index 0000000..b6f401a --- /dev/null +++ b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/ponderisana tacka-novi standard/zad 1/zad 1.vcxproj.filters @@ -0,0 +1,36 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Header Files + + + Header Files + + + Header Files + + + + + Source Files + + + Source Files + + + \ No newline at end of file diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/racun-novi standard/main4.cpp b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/racun-novi standard/main4.cpp new file mode 100644 index 0000000..13edf25 --- /dev/null +++ b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/racun-novi standard/main4.cpp @@ -0,0 +1,16 @@ +#include "predmet.h" +#include "zbirka.h" +#include "stavka.h" +#include "racun.h" + +int main() { + Racun racun(5, "Aroma market", 21112014); + + racun += Stavka("Hleb", 40.5, 4); + racun += Stavka("Mleko", 97.2, 10); + racun += Stavka("Secer", 42.5, 5); + + cout << racun << endl; + + return 0; +} \ No newline at end of file diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/racun-novi standard/metode4.cpp b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/racun-novi standard/metode4.cpp new file mode 100644 index 0000000..ab86886 --- /dev/null +++ b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/racun-novi standard/metode4.cpp @@ -0,0 +1,38 @@ +#include "predmet.h" +#include "zbirka.h" +#include "stavka.h" +#include "racun.h" + +void Zbirka::brisi() { + if (pniz == nullptr) return; + + for (int i=0; ikopija(); //poziva polimorfno kopiranje +} + +void Zbirka::pisi(ostream &it) const { + for (int i=0; ivelicina(); + return suma; +} + +void Racun::pisi(ostream &it) const { + it << ime << " " << datum << endl; + Zbirka::pisi(it); //spisak stavki + it << endl << zbirVelicina() << endl; +} \ No newline at end of file diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/racun-novi standard/predmet.h b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/racun-novi standard/predmet.h new file mode 100644 index 0000000..56ba282 --- /dev/null +++ b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/racun-novi standard/predmet.h @@ -0,0 +1,23 @@ +#ifndef _PREDMET_H_ +#define _PREDMET_H_ + +#include +using namespace std; + +class Predmet { +protected: + virtual void pisi(ostream &it) const = 0; //apstraktno +public: + virtual ~Predmet() {} //uvek ostavljamo u osnovnoj klasi + + virtual double velicina() const = 0; //apstraktno + + virtual Predmet *kopija() const = 0; //apstraktno (polimorfno) kopiranje + + friend ostream &operator<<(ostream &it, const Predmet &p) { + p.pisi(it); + return it; + } +}; + +#endif \ No newline at end of file diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/racun-novi standard/racun.h b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/racun-novi standard/racun.h new file mode 100644 index 0000000..31811a0 --- /dev/null +++ b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/racun-novi standard/racun.h @@ -0,0 +1,20 @@ +#ifndef _RACUN_H_ +#define _RACUN_H_ + +#include "zbirka.h" +#include "predmet.h" +#include "stavka.h" + +class Racun : public Zbirka { +protected: + string ime; + long datum; + + void pisi(ostream &it) const; +public: + Racun(int kkap, const string &im, long dat) : Zbirka(kkap), ime(im) { datum = dat; } + + Racun *kopija() const { return new Racun(*this); } +}; + +#endif \ No newline at end of file diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/racun-novi standard/stavka.h b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/racun-novi standard/stavka.h new file mode 100644 index 0000000..5220fe5 --- /dev/null +++ b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/racun-novi standard/stavka.h @@ -0,0 +1,26 @@ +#ifndef _STAVKA_H_ +#define _STAVKA_H_ + +#include + +#include "predmet.h" + +class Stavka : public Predmet { +protected: + string naziv; + double jedcena, kol; + + void pisi(ostream &it) const { + it << naziv << "/" << kol << "," << jedcena; //ovo nije rekao kako da se pise + } +public: + Stavka(const string &naz, double jc, double k) : naziv(naz) { + jedcena = jc; kol = k; + } + + double velicina() const { return kol*jedcena; } + + Stavka *kopija() const { return new Stavka(*this); } +}; + +#endif \ No newline at end of file diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/racun-novi standard/zbirka.h b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/racun-novi standard/zbirka.h new file mode 100644 index 0000000..8d18f2d --- /dev/null +++ b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/racun-novi standard/zbirka.h @@ -0,0 +1,68 @@ +#ifndef _ZBIRKA_H_ +#define _ZBIRKA_H_ + +#include "predmet.h" + +class Zbirka { +private: + void brisi(); + + void kopiraj(const Zbirka &z); + + void premesti(Zbirka &z) { //ovde prima referencu na l-vrednost, a salje se referenca na d-vrednost + kap = z.kap; + pop = z.pop; + pniz = z.pniz; + z.pniz = nullptr; + } +protected: + Predmet **pniz; //sadrzi pokazivace na predmete, jer predmet ne moze da postoji samostalno jer je apstraktna klasa + int kap, pop; + + virtual void pisi(ostream &it) const; +public: + explicit Zbirka(int kkap) { + kap = kkap; + pop = 0; + pniz = new Predmet *[kap]; + } + + virtual ~Zbirka() { brisi(); } + + Zbirka(const Zbirka &z) { kopiraj(z); } + + Zbirka(Zbirka &&z) { premesti(z); } + + Zbirka &operator=(const Zbirka &z) { + if (this != &z) { + brisi(); + kopiraj(z); + } + return *this; + } + + Zbirka &operator=(Zbirka &&z) { + if (this != &z) { + brisi(); + premesti(z); + } + return *this; + } + + virtual Zbirka *kopija() const { return new Zbirka(*this); } + + bool operator+=(const Predmet &p) { + if (kap == pop) return false; + pniz[pop++] = p.kopija(); + return true; + } + + double zbirVelicina() const; + + friend ostream &operator<<(ostream &it, const Zbirka &z) { + z.pisi(it); + return it; + } +}; + +#endif \ No newline at end of file diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/uredjena zbirka-novi standard/main1.cpp b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/uredjena zbirka-novi standard/main1.cpp new file mode 100644 index 0000000..a0d9980 --- /dev/null +++ b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/uredjena zbirka-novi standard/main1.cpp @@ -0,0 +1,42 @@ +#include "zbirka.h" +#include "uredjena.h" +#include "skup.h" + +int main() { + while (true) { + + cout << "Izaberi: 1. Zbirka 2. Uredjena zbirka 3. Skup 4. Kraj"; + int tip; + cin >> tip; + if (tip != 1 && tip != 2 && tip != 3) break; + + Zbirka *z = nullptr; + + int kap, korak; + cout << "Kapacitet, korak: "; + cin >> kap >> korak; + switch (tip) { + case 1: z = new Zbirka(kap, korak); + break; + case 2: z = new Uredjena(kap, korak); + break; + case 3: z = new Skup(kap, korak); + break; + } + + //dodajemo elemente + while (true) { + cout << "Unesi broj, 0 za kraj: "; + int broj; + cin >> broj; + if (broj == 0) break; + + *z += broj; + } + + cout << *z << endl; + + delete z; + } + return 0; +} \ No newline at end of file diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/uredjena zbirka-novi standard/metode1.cpp b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/uredjena zbirka-novi standard/metode1.cpp new file mode 100644 index 0000000..6d5e7b1 --- /dev/null +++ b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/uredjena zbirka-novi standard/metode1.cpp @@ -0,0 +1,59 @@ +#include "zbirka.h" +#include "uredjena.h" +#include "skup.h" + +void Zbirka::kopiraj(const Zbirka &z) { + kap = z.kap; + pop = z.pop; + korak = z.korak; + pniz = new int[kap]; + for (int i=0; i=0 && pniz[i] > broj; i--) pniz[i+1] = pniz[i]; + pniz[i+1] = broj; + pop++; + return *this; +} + +Skup &Skup::operator+=(int broj) { + for (int i=0; i +using namespace std; + +class Zbirka { +private: + void brisi() { + if (pniz == nullptr) return; + delete [] pniz; + } + + void kopiraj(const Zbirka &z); + + void premesti(Zbirka &z) { + kap = z.kap; + pop = z.pop; + korak = z.korak; + pniz = z.pniz; + z.pniz = nullptr; + } +protected: + int *pniz; + int kap, pop, korak; + + virtual void pisi(ostream &it) const; +public: + explicit Zbirka(int kkap=10, int kor=4) { + kap = kkap; + pop = 0; + korak = kor; + pniz = new int[kap]; + } + + Zbirka(const Zbirka &z) { kopiraj(z); } + + Zbirka(Zbirka &&z) { premesti(z); } + + virtual ~Zbirka() { brisi(); } + + Zbirka &operator=(const Zbirka &z) { + if (this != &z) { + brisi(); + kopiraj(z); + } + return *this; + } + + Zbirka &operator=(Zbirka &&z) { + if (this != &z) { + brisi(); + premesti(z); + } + return *this; + } + + //virtuelan, jer se redefinise u izvedenoj klasi + virtual Zbirka &operator+=(int broj); + + virtual Zbirka *kopija() const { return new Zbirka(*this); } //polimorfno kopiranje + + int getPop() const { return pop; } + + const int &operator[](int indeks) const { //moze i samo da vrati int + if (indeks<0 || indeks>pop-1) exit(5); + return pniz[indeks]; + } + + friend ostream &operator<<(ostream &it, const Zbirka &z) { + z.pisi(it); + return it; + } +}; + +#endif \ No newline at end of file diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/valjak-lopta-stari standard-nije idealno/glista.h b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/valjak-lopta-stari standard-nije idealno/glista.h new file mode 100644 index 0000000..7104ec9 --- /dev/null +++ b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/valjak-lopta-stari standard-nije idealno/glista.h @@ -0,0 +1,85 @@ +#ifndef _glista_h_ +#define _glista_h_ + +#include "telo.h" +#include +using namespace std; + +class Glista { +private: + struct Elem { + Telo *telo; + Elem *sled; + + Elem(Telo *t) { telo = t; sled = 0; } + }; + + Elem *poc, *kraj; + int broj; + double tezina; + + void brisi() { + Elem *pom = poc; + while (poc != 0) { + pom = poc; + poc = poc->sled; + delete pom->telo; + delete pom; + } + poc = kraj = 0; broj = 0; tezina = 0; + } + + void kopiraj(Glista &g) { + broj = g.broj; + tezina = g.tezina; + Elem *pom = poc; + while (pom != 0) { + switch (pom->telo->dohvatiVrsta()) { + case 'L' : g += new Lopta(((Lopta *)pom->telo)->dohvatiR(), pom->telo->dohvatiSigma()); + break; + case 'V' : g += new Valjak(((Valjak *)pom->telo)->dohvatiR(), ((Valjak *)pom->telo)->dohvatiH(), pom->telo->dohvatiSigma()); + break; + } + pom = pom->sled; + } + } +public: + Glista() { poc = kraj = 0; broj = 0; tezina = 0; } + + Glista(Glista &g) { kopiraj(g); } + ~Glista() { brisi(); } + Glista &operator=(Glista &g) { + if (this != &g) { + brisi(); kopiraj(g); + } + return *this; + } + + Glista &operator+=(Telo *t) { + if (poc == 0) { + poc = kraj = new Elem(t); + } else { + kraj->sled = new Elem(t); + kraj = kraj->sled; + } + broj++; + tezina += t->tezina(); + + return *this; + } + + double glistatezina() { return tezina; } + + friend ostream &operator<<(ostream &it, Glista &g) { + Glista::Elem *pom = g.poc; + while (pom != 0) { + pom->telo->pisi(it); + it << endl; + pom = pom->sled; + } + return it; + } + +}; + +#endif \ No newline at end of file diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/valjak-lopta-stari standard-nije idealno/lopta.h b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/valjak-lopta-stari standard-nije idealno/lopta.h new file mode 100644 index 0000000..8bdc6b3 --- /dev/null +++ b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/valjak-lopta-stari standard-nije idealno/lopta.h @@ -0,0 +1,21 @@ +#ifndef _lopta_h_ +#define _lopta_h_ + +#include "telo.h" +#include +using namespace std; + +class Lopta : public Telo { +private: + double r; +public: + Lopta(double rr, double ss) : Telo(ss, 'L') { r = rr; } + + double zapremina() { return 4.0/3*r*r*r*3.14; } + + double dohvatiR() { return r; } + + void pisi(ostream &it) { Telo::pisi(it); it << r; } +}; + +#endif \ No newline at end of file diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/valjak-lopta-stari standard-nije idealno/main.cpp b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/valjak-lopta-stari standard-nije idealno/main.cpp new file mode 100644 index 0000000..91f0bc1 --- /dev/null +++ b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/valjak-lopta-stari standard-nije idealno/main.cpp @@ -0,0 +1,15 @@ +#include "telo.h" +#include "valjak.h" +#include "lopta.h" +#include "glista.h" +#include +using namespace std; + +void main() { + Glista g; + Telo *telo = new Lopta(12, 2); + g += telo; + telo = new Valjak(1,2,3); + g += telo; + cout << g; +} \ No newline at end of file diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/valjak-lopta-stari standard-nije idealno/telo.h b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/valjak-lopta-stari standard-nije idealno/telo.h new file mode 100644 index 0000000..7b5ff12 --- /dev/null +++ b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/valjak-lopta-stari standard-nije idealno/telo.h @@ -0,0 +1,23 @@ +#ifndef _telo_h_ +#define _telo_h_ + +#include +using namespace std; + +class Telo { +private: + double sigma; + char vrsta; +public: + Telo(double ss, char vv) { sigma = ss; vrsta = vv; } + + virtual double zapremina() { return 0; } + double tezina() { return zapremina()*sigma; } + + char dohvatiVrsta() { return vrsta; } + double dohvatiSigma() { return sigma; } + + virtual void pisi(ostream &it) { it << vrsta << ":" << sigma; } +}; + +#endif; \ No newline at end of file diff --git a/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/valjak-lopta-stari standard-nije idealno/valjak.h b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/valjak-lopta-stari standard-nije idealno/valjak.h new file mode 100644 index 0000000..1330955 --- /dev/null +++ b/Labovi/OO1-Lab2-Sve_godine_svi_zadaci/valjak-lopta-stari standard-nije idealno/valjak.h @@ -0,0 +1,22 @@ +#ifndef _valjak_h_ +#define _valjak_h_ + +#include "telo.h" +#include +using namespace std; + +class Valjak : public Telo { +private: + double r, h; +public: + Valjak(double rr, double hh, double ss) : Telo(ss, 'V') { r = rr; h = hh;} + + double zapremina() { return r*r*3.14*h; } + + double dohvatiR() { return r; } + double dohvatiH() { return h; } + + void pisi(ostream &it) { Telo::pisi(it); it << r << "," << h; } +}; + +#endif \ No newline at end of file