Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- RasporedLetova RasporedLetova::operator+=(Let& novi) {
- if (_brojRegistrovanihLetova == _maksimalanBrojLetova)
- return *this;
- _letovi[_brojRegistrovanihLetova] = new Let(novi);
- _brojRegistrovanihLetova++;
- bool flag = true;
- while (flag == true)
- {
- flag = false;
- for (int i = 0; i < _brojRegistrovanihLetova; i++)
- {
- if (i + 1 < _brojRegistrovanihLetova)
- {
- Vrijeme prvi = _letovi[i]->GetOcekivanoVrijemePolijetanja(), drugi = _letovi[i + 1]->GetOcekivanoVrijemePolijetanja();
- if (prvi < drugi)
- {
- Let temp(*_letovi[i]);delete _letovi[i];
- _letovi[i] = new Let(*_letovi[i + 1]); delete _letovi[i + 1];
- _letovi[i + 1] = new Let(temp);
- flag = true;
- }
- }
- }
- }
- return *this;
- }
- RasporedLetova RasporedLetova::operator-=(Let& zaUklonit)
- {
- int pozicija = 0;
- for (int i = 0; i < _brojRegistrovanihLetova; i++)
- {
- if (zaUklonit == *_letovi[i])
- {
- delete _letovi[i]; _letovi[i] = nullptr;
- pozicija = i;
- break;
- }
- }
- if (pozicija != 0)
- {
- for (int i = pozicija; i < _brojRegistrovanihLetova; i++)
- {
- Let temp(*_letovi[i]); delete _letovi[i];
- _letovi[i] = new Let(*_letovi[i + 1]); delete _letovi[i + 1];
- _letovi[i + 1] = new Let(temp);
- }
- }
- return *this;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement