Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdlib>
- #include <iostream>
- #include <vector>
- #include <string>#include <cstdlib>
- #include <iostream>
- #include <vector>
- #include <string>
- #include <cstring>
- using namespace std;
- //Current Date//
- int cDay = 18; //[1-31]
- int cMonth = 11; //[1-12]
- int cYear = 2014;
- string digits = "01234567890";
- //Class Address//
- class TAddress
- {private:
- string fStreet;
- string fCity;
- int fHouse;
- string fHouse_Letter;
- int fFlat;
- int fCode_begin;
- int fCode_end;
- char fCode[6];
- public:
- //Initializing constructor//
- TAddress() {}
- //Parametric constructor//
- TAddress(string street, string city, int house, string hletter, int flat, int cbegin, int cend)
- { fStreet = street;
- fCity = city;
- fHouse = house;
- fHouse_Letter=hletter;
- fFlat = flat;
- fCode_begin = cbegin;
- fCode_end = cend; }
- //Copy constructor //
- TAddress(const TAddress&m)
- { fStreet=m.fStreet;
- fCity=m.fCity;
- fHouse=m.fHouse;
- fHouse_Letter=m.fHouse_Letter;
- fFlat=m.fFlat;
- fCode_begin=m.fCode_begin;
- fCode_end=m.fCode_end; }
- //Operator =//
- TAddress operator=(const TAddress&m)
- { if (this!=&m)
- { fStreet=m.fStreet;
- fCity=m.fCity;
- fHouse=m.fHouse;
- fHouse_Letter=m.fHouse_Letter;
- fFlat=m.fFlat;
- fCode_begin=m.fCode_begin;
- fCode_end=m.fCode_end; }
- return (*this); }
- //Methods Get//
- string getStreet()
- { return(fStreet); }
- int getHouse()
- { return(fHouse);}
- string getHouseLetter()
- { return(fHouse_Letter);}
- int getFlat()
- { return(fFlat);}
- int getCode_begin()
- {return(fCode_begin);}
- int getCode_end()
- {return(fCode_end);}
- string getCity()
- { return(fCity); }
- string getCode()
- { return(fCode); }
- //Methods Set//
- void setStreet(string street)
- { fStreet = street; }
- void setCity(string city)
- { fCity = city; }
- void setHouse( int h)
- { fHouse = h;}
- void setHouse_Letter ( string hl)
- { fHouse_Letter = hl; }
- void setFlat( int f)
- {fFlat = f;}
- void setCode(string code)
- { char begin_code[2];
- begin_code[0]=code[0];
- begin_code[1]=code[1];
- fCode_begin=atoi(begin_code);
- char end_code[3];
- end_code[0]=code[3];
- end_code[1]=code[4];
- end_code[2]=code[5];
- fCode_end=atoi(end_code);
- for(int i=0;i++;i<6)
- fCode[i]=code[i]; }
- };
- //Class Pesel//
- class TPESEL
- { private:
- int fYear;
- int fMonth;
- int fDay;
- int fAge;
- string fSex;
- string fPesel;
- public:
- //Initializing constructor//
- TPESEL(){}
- //Parametric constructor//
- TPESEL(string pesel)
- {
- //Control-Check
- string checker;
- int intpesel[11];
- for (int i=0;i<11;i++)
- {checker[0]=pesel[i];
- intpesel[i]=atoi(checker.c_str()); }
- int fSum = intpesel[0] + 3*intpesel[1] + 7*intpesel[2] + 9*intpesel[3] + intpesel[4] + 3*intpesel[5] + 7*intpesel[6] + 9*intpesel[7] + intpesel[8] + 3*intpesel[9];
- int fRest = fSum%10;
- //Month//
- string m;
- for (int i = 2; i < 4; i++)
- m[i-2] = pesel[i];
- int mMonth = atoi(m.c_str());
- if (mMonth>12)
- fMonth=mMonth-20;
- else
- fMonth=mMonth;
- //Year//
- string k;
- if (mMonth>12)
- k="20";
- else
- k="19";
- for (int i = 0; i < 2; i++)
- k[i+2] = pesel[i];
- fYear = atoi(k.c_str());
- //Day//
- string d;
- for (int i = 4; i < 6; i++)
- d[i-4] = pesel[i];
- fDay = atoi(d.c_str());
- //Age//
- if (cMonth>fMonth)
- fAge = cYear - fYear;
- else
- { if (cMonth<fMonth)
- fAge = cYear - fYear - 1;
- else
- {if (cDay<fDay)
- fAge = cYear - fYear - 1;
- else
- fAge = cYear - fYear; } }
- //Sex//
- if (intpesel[9]%2==1)
- fSex="Male";
- else
- fSex="Female";
- //Pesel//
- for (int i=0;i<11;i++)
- fPesel[i]=pesel[i];
- if (fRest!=(10-intpesel[10])) //invalid PESEL
- fPesel="INVALID PESEL";
- }
- //COPY CONTRUSCTOR//
- TPESEL(const TPESEL&m)
- { fYear = m.fYear;
- fMonth = m.fMonth;
- fDay = m.fDay;
- fAge = m.fAge;
- fSex = m.fSex;
- fPesel = m.fPesel; }
- //OPERATOR =//
- TPESEL operator=(const TPESEL&m)
- {
- if (this != &m)
- {
- fYear = m.fYear;
- fMonth = m.fMonth;
- fDay = m.fDay;
- fAge = m.fAge;
- fSex = m.fSex;
- fPesel = m.fPesel; }
- return (*this);
- }
- //methods get//
- int getAge()
- { return (fAge);}
- int getDay()
- { return (fDay);}
- int getMonth()
- { return (fMonth);}
- int getYear()
- { return (fYear);}
- string getSex()
- { return (fSex);}
- string getPesel()
- { return (fPesel);}
- };
- //Class Person//
- class TPerson
- { public:
- string fName;
- string fSurname;
- TAddress fAddress;
- TPESEL fPESEL_P;
- //Initializing constructor//
- TPerson(){}
- //Parametric constructor//
- TPerson(string pname, string sname, string ppesel)
- { fName=pname;
- fSurname=sname;
- TPESEL newpesel(ppesel);
- fPESEL_P=newpesel; }
- //Copy constructor//
- TPerson (const TPerson&m)
- { fName=m.fName;
- fSurname = m.fSurname;
- fAddress = m.fAddress;
- fPESEL_P=m.fPESEL_P;}
- //operator=//
- TPerson operator=(const TPerson&m)
- { if (this!=&m)
- {fName=m.fName;
- fSurname = m.fSurname;
- fAddress = m.fAddress;
- fPESEL_P=m.fPESEL_P; }
- return (*this); }
- //Methods GET [Pesel]//
- int getAge()
- { return (fPESEL_P.getAge());}
- int getDay()
- { return (fPESEL_P.getDay());}
- int getMonth()
- { return (fPESEL_P.getMonth());}
- int getYear()
- { return (fPESEL_P.getYear());}
- string getSex()
- { return (fPESEL_P.getSex());}
- string getPesel()
- { return (fPESEL_P.getPesel());}
- //Methods SET [Pesel]//
- void setPesel(string pesel)
- { TPESEL newpesel(pesel);
- fPESEL_P=newpesel; }
- //Methods SET [Address]//
- void setStreet(string street)
- { fAddress.setStreet(street); }
- void setCity(string city)
- { fAddress.setCity(city); }
- void setHouse( int h)
- { fAddress.setHouse(h);}
- void setHouse_Letter ( string hl)
- { fAddress.setHouse_Letter(hl); }
- void setFlat( int f)
- { fAddress.setFlat(f);}
- void setCode(string code)
- { fAddress.setCode(code);}
- //Methods Get [Address]//
- string getStreet()
- { return(fAddress.getStreet()); }
- int getHouse()
- { return(fAddress.getHouse());}
- string getHouseLetter()
- { return(fAddress.getHouseLetter());}
- int getFlat()
- { return(fAddress.getFlat());}
- int getCode_begin()
- {return(fAddress.getCode_begin());}
- int getCode_end()
- {return(fAddress.getCode_end());}
- string getCity()
- { return(fAddress.getCity()); }
- string getCode()
- { return(fAddress.getCode()); }
- //Get Name, Surname//
- string getName()
- { return (fName);}
- string getSurname()
- { return (fSurname);}
- };
- class DB
- {
- public:
- vector <TPerson> dataBase;
- //Initializing constructor//
- DB(){}
- //Copy constructor
- DB(const DB&m)
- {}
- //Add and Remove people from DataBase//
- void addPerson(TPerson newPerson)
- { dataBase.push_back(newPerson); }
- void removePerson(string pesel)
- { for (int i=0;dataBase.size();i++)
- { if (dataBase[i].getPesel()==pesel)
- { dataBase.erase(dataBase.begin()+i);
- i--; } } }
- //Find Person//
- /*nie dziala
- string findNameByPesel(string pesel)
- { string answer="Not Found";
- for (int i=0;dataBase.size();i++)
- { if (dataBase[i].getPesel()==pesel)
- { answer= dataBase[i].getName() + " " + dataBase[i].getSurname();
- break; }
- return(answer); } }
- string findPeselByName (string name, string surname)
- {}
- */
- };
- int main()
- {
- TPerson nowy("Jacek","Ziembla","93071308496");
- nowy.setStreet("Orlich Gniazd");
- nowy.setHouse(31);
- nowy.setCity("Krakow");
- nowy.setCode("31-335");
- cout << "Name: " << nowy.fName << endl;
- cout << "Surname: " << nowy.fSurname << endl;
- cout << "Born: " << nowy.getDay() << '-' << nowy.getMonth() << '-'<< nowy.getYear() << endl;
- cout << "Age: " << nowy.getAge() << endl;
- cout << "Sex: " << nowy.getSex() << endl;
- cout << "PESEL: " << nowy.getPesel().c_str() << endl;
- cout << "Address: " << nowy.getStreet().c_str() << " " << nowy.getHouse() << "," << endl;
- cout << " " << nowy.getCode_begin() << '-' << nowy.getCode_end() << ", " << nowy.getCity().c_str() << endl;
- TPerson a1("Dariusz","Staszczyk","07321909230");
- TPerson a2("Muniek","Staszczyk","98021311195");
- TPerson a3("Mariusz","Stachu","60012015858");
- TPerson a4("Omar","Juras","71080306791");
- TPerson a5("Witalij","Kliczko","71082102432");
- DB mybase;
- mybase.addPerson(nowy);
- mybase.addPerson(a1);
- mybase.addPerson(a2);
- mybase.addPerson(a3);
- mybase.addPerson(a4);
- mybase.addPerson(a5);
- //cout << mybase.findNameByPesel("60012015858").c_str;
- system("PAUSE");
- return EXIT_SUCCESS;
- }
- #include <cstring>
- using namespace std;
- //Current Date//
- int cDay = 18; //[1-31]
- int cMonth = 11; //[1-12]
- int cYear = 2014;
- string digits = "01234567890";
- //Class Address//
- class TAddress
- {private:
- string fStreet;
- string fCity;
- int fHouse;
- string fHouse_Letter;
- int fFlat;
- int fCode_begin;
- int fCode_end;
- char fCode[6];
- public:
- //Initializing constructor//
- TAddress() {}
- //Parametric constructor//
- TAddress(string street, string city, int house, string hletter, int flat, int cbegin, int cend)
- { fStreet = street;
- fCity = city;
- fHouse = house;
- fHouse_Letter=hletter;
- fFlat = flat;
- fCode_begin = cbegin;
- fCode_end = cend; }
- //Copy constructor //
- TAddress(const TAddress&m)
- { fStreet=m.fStreet;
- fCity=m.fCity;
- fHouse=m.fHouse;
- fHouse_Letter=m.fHouse_Letter;
- fFlat=m.fFlat;
- fCode_begin=m.fCode_begin;
- fCode_end=m.fCode_end; }
- //Operator =//
- TAddress operator=(const TAddress&m)
- { if (this!=&m)
- { fStreet=m.fStreet;
- fCity=m.fCity;
- fHouse=m.fHouse;
- fHouse_Letter=m.fHouse_Letter;
- fFlat=m.fFlat;
- fCode_begin=m.fCode_begin;
- fCode_end=m.fCode_end; }
- return (*this); }
- //Methods Get//
- string getStreet()
- { return(fStreet); }
- int getHouse()
- { return(fHouse);}
- string getHouseLetter()
- { return(fHouse_Letter);}
- int getFlat()
- { return(fFlat);}
- int getCode_begin()
- {return(fCode_begin);}
- int getCode_end()
- {return(fCode_end);}
- string getCity()
- { return(fCity); }
- string getCode()
- { return(fCode); }
- //Methods Set//
- void setStreet(string street)
- { fStreet = street; }
- void setCity(string city)
- { fCity = city; }
- void setHouse( int h)
- { fHouse = h;}
- void setHouse_Letter ( string hl)
- { fHouse_Letter = hl; }
- void setFlat( int f)
- {fFlat = f;}
- void setCode(string code)
- { char begin_code[2];
- begin_code[0]=code[0];
- begin_code[1]=code[1];
- fCode_begin=atoi(begin_code);
- char end_code[3];
- end_code[0]=code[3];
- end_code[1]=code[4];
- end_code[2]=code[5];
- fCode_end=atoi(end_code);
- for(int i=0;i++;i<6)
- fCode[i]=code[i]; }
- };
- //Class Pesel//
- class TPESEL
- { private:
- int fYear;
- int fMonth;
- int fDay;
- int fAge;
- string fSex;
- string fPesel;
- public:
- //Initializing constructor//
- TPESEL(){}
- //Parametric constructor//
- TPESEL(string pesel)
- {
- //Control-Check
- string checker;
- int intpesel[11];
- for (int i=0;i<11;i++)
- {checker[0]=pesel[i];
- intpesel[i]=atoi(checker.c_str()); }
- int fSum = intpesel[0] + 3*intpesel[1] + 7*intpesel[2] + 9*intpesel[3] + intpesel[4] + 3*intpesel[5] + 7*intpesel[6] + 9*intpesel[7] + intpesel[8] + 3*intpesel[9];
- int fRest = fSum%10;
- //Month//
- string m;
- for (int i = 2; i < 4; i++)
- m[i-2] = pesel[i];
- int mMonth = atoi(m.c_str());
- if (mMonth>12)
- fMonth=mMonth-20;
- else
- fMonth=mMonth;
- //Year//
- string k;
- if (mMonth>12)
- k="20";
- else
- k="19";
- for (int i = 0; i < 2; i++)
- k[i+2] = pesel[i];
- fYear = atoi(k.c_str());
- //Day//
- string d;
- for (int i = 4; i < 6; i++)
- d[i-4] = pesel[i];
- fDay = atoi(d.c_str());
- //Age//
- if (cMonth>fMonth)
- fAge = cYear - fYear;
- else
- { if (cMonth<fMonth)
- fAge = cYear - fYear - 1;
- else
- {if (cDay<fDay)
- fAge = cYear - fYear - 1;
- else
- fAge = cYear - fYear; } }
- //Sex//
- if (intpesel[9]%2==1)
- fSex="Male";
- else
- fSex="Female";
- //Pesel//
- for (int i=0;i<11;i++)
- fPesel[i]=pesel[i];
- if (fRest!=(10-intpesel[10])) //invalid PESEL
- fPesel="INVALID PESEL";
- }
- //COPY CONTRUSCTOR//
- TPESEL(const TPESEL&m)
- { fYear = m.fYear;
- fMonth = m.fMonth;
- fDay = m.fDay;
- fAge = m.fAge;
- fSex = m.fSex;
- fPesel = m.fPesel; }
- //OPERATOR =//
- TPESEL operator=(const TPESEL&m)
- {
- if (this != &m)
- {
- fYear = m.fYear;
- fMonth = m.fMonth;
- fDay = m.fDay;
- fAge = m.fAge;
- fSex = m.fSex;
- fPesel = m.fPesel; }
- return (*this);
- }
- //methods get//
- int getAge()
- { return (fAge);}
- int getDay()
- { return (fDay);}
- int getMonth()
- { return (fMonth);}
- int getYear()
- { return (fYear);}
- string getSex()
- { return (fSex);}
- string getPesel()
- { return (fPesel);}
- };
- //Class Person//
- class TPerson
- { public:
- string fName;
- string fSurname;
- TAddress fAddress;
- TPESEL fPESEL_P;
- //Initializing constructor//
- TPerson(){}
- //Parametric constructor//
- TPerson(string pname, string sname, string ppesel)
- { fName=pname;
- fSurname=sname;
- TPESEL newpesel(ppesel);
- fPESEL_P=newpesel; }
- //Copy constructor//
- TPerson (const TPerson&m)
- { fName=m.fName;
- fSurname = m.fSurname;
- fAddress = m.fAddress;
- fPESEL_P=m.fPESEL_P;}
- //operator=//
- TPerson operator=(const TPerson&m)
- { if (this!=&m)
- {fName=m.fName;
- fSurname = m.fSurname;
- fAddress = m.fAddress;
- fPESEL_P=m.fPESEL_P; }
- return (*this); }
- //Methods GET [Pesel]//
- int getAge()
- { return (fPESEL_P.getAge());}
- int getDay()
- { return (fPESEL_P.getDay());}
- int getMonth()
- { return (fPESEL_P.getMonth());}
- int getYear()
- { return (fPESEL_P.getYear());}
- string getSex()
- { return (fPESEL_P.getSex());}
- string getPesel()
- { return (fPESEL_P.getPesel());}
- //Methods SET [Pesel]//
- void setPesel(string pesel)
- { TPESEL newpesel(pesel);
- fPESEL_P=newpesel; }
- //Methods SET [Address]//
- void setStreet(string street)
- { fAddress.setStreet(street); }
- void setCity(string city)
- { fAddress.setCity(city); }
- void setHouse( int h)
- { fAddress.setHouse(h);}
- void setHouse_Letter ( string hl)
- { fAddress.setHouse_Letter(hl); }
- void setFlat( int f)
- { fAddress.setFlat(f);}
- void setCode(string code)
- { fAddress.setCode(code);}
- //Methods Get [Address]//
- string getStreet()
- { return(fAddress.getStreet()); }
- int getHouse()
- { return(fAddress.getHouse());}
- string getHouseLetter()
- { return(fAddress.getHouseLetter());}
- int getFlat()
- { return(fAddress.getFlat());}
- int getCode_begin()
- {return(fAddress.getCode_begin());}
- int getCode_end()
- {return(fAddress.getCode_end());}
- string getCity()
- { return(fAddress.getCity()); }
- string getCode()
- { return(fAddress.getCode()); }
- //Get Name, Surname//
- string getName()
- { return (fName);}
- string getSurname()
- { return (fSurname);}
- };
- class DB
- {
- public:
- vector <TPerson> dataBase;
- //Initializing constructor//
- DB(){}
- //Copy constructor
- DB(const DB&m)
- {}
- //Add and Remove people from DataBase//
- void addPerson(TPerson newPerson)
- { dataBase.push_back(newPerson); }
- void removePerson(string pesel)
- { for (int i=0;dataBase.size();i++)
- { if (dataBase[i].getPesel()==pesel)
- { dataBase.erase(dataBase.begin()+i);
- i--; } } }
- //Find Person//
- /*nie dziala
- string findNameByPesel(string pesel)
- { string answer="Not Found";
- for (int i=0;dataBase.size();i++)
- { if (dataBase[i].getPesel()==pesel)
- { answer= dataBase[i].getName() + " " + dataBase[i].getSurname();
- break; }
- return(answer); } }
- string findPeselByName (string name, string surname)
- {}
- */
- };
- int main()
- {
- TPerson nowy("Jacek","Ziembla","93071308496");
- nowy.setStreet("Orlich Gniazd");
- nowy.setHouse(31);
- nowy.setCity("Krakow");
- nowy.setCode("31-335");
- cout << "Name: " << nowy.fName << endl;
- cout << "Surname: " << nowy.fSurname << endl;
- cout << "Born: " << nowy.getDay() << '-' << nowy.getMonth() << '-'<< nowy.getYear() << endl;
- cout << "Age: " << nowy.getAge() << endl;
- cout << "Sex: " << nowy.getSex() << endl;
- cout << "PESEL: " << nowy.getPesel().c_str() << endl;
- cout << "Address: " << nowy.getStreet().c_str() << " " << nowy.getHouse() << "," << endl;
- cout << " " << nowy.getCode_begin() << '-' << nowy.getCode_end() << ", " << nowy.getCity().c_str() << endl;
- TPerson a1("Dariusz","Staszczyk","07321909230");
- TPerson a2("Muniek","Staszczyk","98021311195");
- TPerson a3("Mariusz","Stachu","60012015858");
- TPerson a4("Omar","Juras","71080306791");
- TPerson a5("Witalij","Kliczko","71082102432");
- DB mybase;
- mybase.addPerson(nowy);
- mybase.addPerson(a1);
- mybase.addPerson(a2);
- mybase.addPerson(a3);
- mybase.addPerson(a4);
- mybase.addPerson(a5);
- //cout << mybase.findNameByPesel("60012015858").c_str;
- system("PAUSE");
- return EXIT_SUCCESS;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement