Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Ucenik{
- private:
- string ime;
- double prosek;
- int skolska_godina;
- public:
- Ucenik(){
- }
- Ucenik(string _ime, double _prosek, int _skolska_godina){
- ime = _ime;
- prosek = _prosek;
- skolska_godina = _skolska_godina;
- }
- Ucenik & operator ++ (int i){
- skolska_godina++;
- return *this;
- }
- friend ostream & operator << (ostream & stream, Ucenik u);
- bool operator > (Ucenik tmp) {
- if(prosek > tmp.prosek){
- return true;
- }
- return false;
- }
- double get_prosek() {
- return prosek;
- }
- };
- ostream & operator << (ostream & stream, Ucenik u) {
- stream << u.ime << " " << u.prosek << " " << u.skolska_godina << endl;
- return stream;
- }
- class Paralelka {
- private:
- int n;
- Ucenik * niza;
- public:
- Paralelka () {}
- Paralelka(int _n) {
- n = _n;
- niza = new Ucenik[n];
- }
- Paralelka & operator += (Ucenik u) {
- Ucenik tmp[n + 1];
- for(int i = 0; i < n; i++) {
- tmp[i] = niza[i];
- }
- tmp[n] = u;
- n++;
- niza = new Ucenik[n];
- for(int i = 0; i < n; i++) {
- niza[i] = tmp[i];
- }
- return *this;
- }
- Paralelka & operator ++ (int i) {
- for(int i = 0; i < n; i++) {
- niza[i]++;
- }
- return *this;
- }
- void nagrada() {
- for(int i = 0; i < n; i++) {
- if(niza[i].get_prosek() == 10.0) {
- cout << niza[i];
- }
- }
- }
- void najvisokProsek() {
- double najgolem_prosek = 0.0;
- int idx = 0;
- for(int i = 0; i < n; i++) {
- if(niza[i].get_prosek() > najgolem_prosek) {
- najgolem_prosek = niza[i].get_prosek();
- idx = i;
- }
- }
- cout << niza[idx];
- }
- friend ostream & operator << (ostream & stream, Paralelka tmp);
- };
- ostream & operator << (ostream & stream, Paralelka tmp) {
- for(int i = 0; i < tmp.n; i++) {
- stream << tmp.niza[i];
- }
- return stream;
- }
- int main()
- {
- Ucenik u1("Martina Martinovska", 9.5, 3);
- Ucenik u2("Darko Darkoski", 7.3, 2);
- Ucenik u3("Angela Angelovska", 10, 3);
- Paralelka p(0);
- p += u1;
- p += u2;
- p += u3;
- cout << p;
- cout << "Nagradeni:" << endl;
- p.nagrada();
- cout << endl;
- p.najvisokProsek();
- cout << endl;
- u2++;
- cout << p;
- cout << endl;
- p++;
- cout << p;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement