Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef PAZIENTE_H
- #define PAZIENTE_H
- #include <iostream>
- #include <string>
- using namespace std;
- enum CodiceUrgenza {BIANCO = 0, VERDE, GIALLO, ROSSO};
- class Paziente
- {
- private:
- string nome;
- CodiceUrgenza codice;
- public:
- Paziente() : nome(""), codice(BIANCO) {}
- Paziente(string n, CodiceUrgenza c) : nome(n), codice(c) {}
- CodiceUrgenza getCodice() const { return codice; }
- void setCodice(CodiceUrgenza codice) { this->codice = codice; }
- const string& getNome() const { return nome; }
- void setNome(const string& nome) { this->nome = nome; }
- bool operator==(const Paziente& p) const { return codice == p.codice; }
- bool operator<(const Paziente& p) const { return codice < p.codice; }
- bool operator<=(const Paziente& p) const { return codice <= p.codice; }
- bool operator>(const Paziente& p) const { return codice > p.codice; }
- bool operator>=(const Paziente& p) const { return codice >= p.codice; }
- };
- #endif
- /*Utilizzare l’ereditarietà per realizzare la classe CodaPazienti che implementi una coda con priorità di pazienti, in cui i pazienti che arrivano sono serviti in base al codice di urgenza (da rosso a bianco) e, a parità di urgenza, nel consueto ordine FIFO (First In First Out).*/
- #ifndef CODAPAZIENTI_H
- #define CODAPAZIENTI_H
- #include<list>
- #include"paziente.h"
- class CodaPazienti: public list<Paziente>
- {
- public:
- void aggiungi(const Paziente& p)
- {
- list<Paziente>::iterator it=this->begin();
- while(it!=this->end() && (*it)>=p)
- it++;
- insert(it,p);
- }
- void pop_front(){list<Paziente>::pop_front();}
- //string front(){return list<Paziente>::front();}
- //string back(){return list<Paziente>::back();}
- //int size(){return list<Paziente>::size();}
- bool empty(){return list<Paziente>::empty();}
- void print(){for(list<Paziente>::iterator i=this->begin(); i!=this->end(); i++) cout<<(*i).getNome()<<" ";}
- };
- #endif
- #include"codapazienti.h"
- int main()
- {
- CodaPazienti A;
- Paziente B ("Harry",BIANCO);
- Paziente C ("Rohn",GIALLO);
- Paziente D ("Ciccio",ROSSO);
- Paziente E ("BOMBO",VERDE);
- Paziente F ("Giulia_Valentinaaa",ROSSO);
- A.aggiungi(B);
- A.aggiungi(C);
- A.aggiungi(F);
- A.aggiungi(E);
- A.aggiungi(D);
- A.print();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement