Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Volonter.h"
- void Zivotinja::DodajZivotinju()
- {
- cout << "1 - Pas" << endl;
- cout << "2 - Macka" << endl;
- cout << "Izaberite zivotinju:";
- int nZiv = 0;
- cin >> nZiv;
- while (nZiv < 1 || nZiv > 2)
- {
- cout << "Izaberite zivotinju:";
- cin >> nZiv;
- }
- cout << "Unesite sifru zivotinje:";
- string sSifra;
- cin >> sSifra;
- cout << "Unesite ime zivotinje:";
- string sIme;
- cin >> sIme;
- cout << "Unesite vrstu zivotinje:";
- cin.clear();
- cin.ignore(INT_MAX, '\n');
- string sVrsta;
- getline(cin, sVrsta);
- cout << "Unesite dob zivotinje u mjesecima:";
- int nDob;
- cin >> nDob;
- cout << "1 - Cipirana" << endl;
- cout << "2 - Nije cipirana" << endl;
- cout << "Izaberite status cipiranja:";
- int nCip;
- cin >> nCip;
- while (nCip < 1 || nCip > 2)
- {
- cout << "Izaberite status cipiranja:";
- cin >> nCip;
- }
- cout << "1 - Zdrava" << endl;
- cout << "2 - Bolesna" << endl;
- cout << "3 - Mrtva" << endl;
- cout << "Izaberite zdravstveno stanje:";
- int nZdrav;
- cin >> nZdrav;
- while (nZdrav < 1 || nZdrav > 3)
- {
- cout << "Izaberite zdravstveno stanje:";
- cin >> nZdrav;
- }
- vector<Volonter> vVolonteri;
- vector<Volonter>::iterator iPos;
- XMLDocument oXmlDocument;
- oXmlDocument.LoadFile("volonteri.xml");
- XMLElement *pRoot = oXmlDocument.FirstChildElement("volonteri");
- XMLElement *pChild;
- vVolonteri.clear();
- for (pChild = pRoot->FirstChildElement("volonter"); pChild != NULL; pChild = pChild->NextSiblingElement())
- {
- string sIme = pChild->Attribute("ime");
- string sPrezime = pChild->Attribute("prezime");
- string sBroj = pChild->Attribute("broj");
- string sKorisIme = pChild->Attribute("korisnicko_ime");
- string sLozinka = pChild->Attribute("lozinka");
- vVolonteri.push_back(Volonter(sBroj, sKorisIme, sLozinka, sIme, sPrezime));
- }
- for (iPos = vVolonteri.begin(); iPos != vVolonteri.end(); ++iPos)
- {
- cout << (iPos)->DajBroj() << " " << (iPos)->ime << " " << (iPos)->prezime << endl;
- }
- cout << "Izaberite sifru volontera:";
- int nVolonter;
- cin >> nVolonter;
- string sVolonter = to_string(nVolonter);
- int nPomocna = 0;
- for (iPos = vVolonteri.begin(); iPos != vVolonteri.end(); ++iPos)
- {
- if ((iPos)->DajBroj() == sVolonter)
- {
- nPomocna = 1;
- break;
- }
- }
- while (nPomocna == 0)
- {
- for (iPos = vVolonteri.begin(); iPos != vVolonteri.end(); ++iPos)
- {
- cout << (iPos)->DajBroj() << " " << (iPos)->ime << " " << (iPos)->prezime << endl;
- }
- cout << "Izaberite sifru volontera:";
- cin >> nVolonter;
- sVolonter = to_string(nVolonter);
- for (iPos = vVolonteri.begin(); iPos != vVolonteri.end(); ++iPos)
- {
- if ((iPos)->DajBroj() == sVolonter)
- {
- nPomocna = 1;
- break;
- }
- }
- }
- cout << "Unesite datum prijave u skloniste(1.1.2019.):";
- string sDatum;
- cin >> sDatum;
- XMLDocument xmlDoc;
- xmlDoc.LoadFile(XML_Zivotinje.c_str());
- if (nZiv == 1)
- {
- XMLElement *pRoota = xmlDoc.FirstChildElement("zivotinje");
- XMLElement *pRoota2 = pRoota->FirstChildElement("psi");
- XMLElement *pElementa = xmlDoc.NewElement("pas");
- pElementa->SetAttribute("sifra", sSifra.c_str());
- pElementa->SetAttribute("ime", sIme.c_str());
- pElementa->SetAttribute("vrsta", sVrsta.c_str());
- pElementa->SetAttribute("dob_u_mjesecima", nDob);
- if (nCip == 1)
- {
- pElementa->SetAttribute("informacije_o_cipiranju", "Cipirana");
- }
- else
- {
- pElementa->SetAttribute("informacije_o_cipiranju", "Nije cipirana");
- }
- if (nZdrav == 1)
- {
- pElementa->SetAttribute("informacije_o_zdravstvenom_stanju", "Zdrava");
- }
- else if (nZdrav == 2)
- {
- pElementa->SetAttribute("informacije_o_zdravstvenom_stanju", "Bolesna");
- }
- else
- {
- pElementa->SetAttribute("informacije_o_zdravstvenom_stanju", "Mrtva");
- }
- pElementa->SetAttribute("sifra_volontera", nVolonter);
- pElementa->SetAttribute("datum_prve_pojave", sDatum.c_str());
- pRoota2->InsertEndChild(pElementa);
- }
- else
- {
- XMLElement *pRoota = xmlDoc.FirstChildElement("zivotinje");
- XMLElement *pRoota2 = pRoota->FirstChildElement("macke");
- XMLElement *pElementa = xmlDoc.NewElement("macka");
- pElementa->SetAttribute("sifra", sSifra.c_str());
- pElementa->SetAttribute("ime", sIme.c_str());
- pElementa->SetAttribute("vrsta", sVrsta.c_str());
- pElementa->SetAttribute("dob_u_mjesecima", nDob);
- if (nCip == 1)
- {
- pElementa->SetAttribute("informacije_o_cipiranju", "Cipirana");
- }
- else
- {
- pElementa->SetAttribute("informacije_o_cipiranju", "Nije cipirana");
- }
- if (nZdrav == 1)
- {
- pElementa->SetAttribute("informacije_o_zdravstvenom_stanju", "Zdrava");
- }
- else if (nZdrav == 2)
- {
- pElementa->SetAttribute("informacije_o_zdravstvenom_stanju", "Bolesna");
- }
- else
- {
- pElementa->SetAttribute("informacije_o_zdravstvenom_stanju", "Mrtva");
- }
- pElementa->SetAttribute("sifra_volontera", nVolonter);
- pElementa->SetAttribute("datum_prve_pojave", sDatum.c_str());
- pRoota2->InsertEndChild(pElementa);
- }
- xmlDoc.SaveFile(XML_Zivotinje.c_str());
- cout << "Uspjesno dodana zivotinja!" << endl;
- Izbornik();
- }
Advertisement
Add Comment
Please, Sign In to add comment