Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <cstdlib>
- #include <ctime>
- using namespace std;
- void wyrocznia(){
- string pytanie;
- cout<<"Zadaj zamkniete pytanie"<<endl;
- getline(cin,pytanie);
- bool xd;
- xd=rand()%2;
- if(xd==0)
- cout<<"tak"<<endl;
- else cout<<"nie"<<endl;
- }
- void ustaw_generowanie()
- {
- srand( time( NULL ) );
- }
- string changestring(string &napis){
- string removed;
- cout<<"Podaj co chcesz usunac z napisu"<<endl;
- getline(cin,removed);
- cout<<"Podaj co chcesz wstawic do napisu"<<endl;
- string added;
- getline(cin,added);
- size_t pos = napis.find(removed);
- while(pos!=string::npos) {
- napis.replace(pos,removed.length(),added);
- pos=napis.find(removed,pos+added.size());
- }
- return napis;
- }
- class Villager{
- string name;
- int age;
- int MaxAge;
- bool sex;
- string malesname[5]={"bartek","jacek","tadek","gacek","twoj_stary"};
- string femalesname[5]={"karyna","katarzyna","kurwina","morfina","dopalkracja"};
- public:
- int lifetime(){
- return rand()%101;
- }
- /*string nameL(){
- if(sex==0){
- return femalesname[rand()%5];
- }
- else return malesname[rand()%5];
- } */
- bool sexL(){
- return rand()%2;
- }
- Villager(){
- age=0;
- MaxAge=lifetime();
- sex=sexL();
- if(!sex)
- {
- name=femalesname[rand()%5]; }
- else name=malesname[rand()%5];
- }
- string get_name(){
- return name;
- }
- int get_age(){
- return age;
- }
- int get_MaxAge(){
- return MaxAge;
- }
- bool get_sex(){
- return sex;
- }
- void czas(){
- age++;
- }
- ~Villager(){
- if(age==MaxAge)
- cout<<name<<" umiera w wieku "<<age<<" lat"<<endl;
- }
- };
- string weryfikuj(Villager p){
- string plec;
- if(p.get_sex()==0){
- return plec="kobieta";
- }
- else return plec="mezczyzna";
- }
- class Household{
- int n;
- Villager *obiekt=new Villager[n];
- public:
- void addage(){
- for(int i=0;i<n;i++){
- obiekt[i].czas();
- }
- }
- void addage2(){
- for(int i=0;i<obiekt->get_MaxAge();i++){
- addage();
- }
- }
- };
- int main(){
- /* string edited;
- string removed;
- string added;
- cout<<"Podaj napis"<<endl;
- getline(cin,edited);
- cout<<"Podaj to co chcesz usunac z napisu"<<endl;
- getline(cin,removed);
- cout<<"Podaj co chcesz podstawic"<<endl;
- getline(cin,added);
- size_t pos=edited.find(removed);
- while(pos!=string::npos) {
- edited.replace(pos,removed.length(), added);
- pos=edited.find(removed,pos+added.size());
- }
- */
- /* string napis;
- cout<<"Podaj napis"<<endl;
- getline(cin,napis);
- changestring(napis);
- cout << napis << endl; */
- ustaw_generowanie();
- Villager zyd;
- Villager zyd2;
- cout<<"Imie: "<<zyd.get_name()<<" "<<"wiek: "<<zyd.get_age()<<" "<<"dlugosc zycia: "<<zyd.get_MaxAge()<<" "<<"plec: "<<weryfikuj(zyd)<<" "<<endl;
- cout<<"Imie: "<<zyd2.get_name()<<" "<<"wiek: "<<zyd2.get_age()<<" "<<"dlugosc zycia: "<<zyd2.get_MaxAge()<<" "<<"plec: "<<weryfikuj(zyd2)<<" "<<endl;
- for(int i=zyd.get_age();i<zyd.get_MaxAge();i++){
- cout<<zyd.get_age()<<endl;
- zyd.czas();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement