Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- class Telepes{
- private:
- string nev,szul_bolygo,bolygo;
- unsigned int ero;
- bool vegan;
- public:
- Telepes();
- const string &get_nev() const;
- void set_nev(const string &nev);
- const string &get_szul_bolygo() const;
- void set_szul_bolygo(const string &szulBolygo);
- const string &get_bolygo() const;
- void set_bolygo(const string &bolygo);
- unsigned int get_ero() const;
- void set_ero(unsigned int ero);
- bool is_vegan() const;
- void set_vegan(const bool &vegan);
- };
- class Kolonia{
- private:
- string nev,bolygo;
- unsigned int letszam;
- Telepes* lakok;
- public:
- unsigned int get_letszam() const;
- const Telepes* get_lakok() const;
- const string &get_nev() const;
- void set_nev(const string &nev);
- const string &get_bolygo() const;
- void set_bolygo(const string &bolygo);
- Kolonia();
- Kolonia(const string &nev, const string &bolygo);
- Kolonia& operator+=(const Telepes &newTelepes) {
- for(int i=0; i<25; i++){
- if(this->lakok[i].get_nev() == ""){
- this->lakok[i] = newTelepes;
- return *this;
- }
- }
- cout << "A kolonia megtelt\n";
- return *this;
- }
- Kolonia& operator~(){
- bool isVeganColony=false;
- int sizeOfColony=0;
- int vegansInColony;
- for(Telepes& lako : this->get_lakok()){
- if(telepesPeldany->nev != ""){
- sizeOfColony++;
- if(telepesPeldany->vegan) vegansInColony++;
- }else{
- if(vegansInColony / sizeOfColony > 0.5 && sizeOfColony > 0)
- return true;
- else return false;
- }
- }
- return
- }
- };
- int main() {
- Telepes elsoTelepesek[26];
- for(int i=0; i<26; i++) {
- elsoTelepesek[i].set_nev("nev");
- elsoTelepesek[i].set_bolygo("Vegeta");
- elsoTelepesek[i].set_vegan(true);
- }
- Kolonia elsoKolonia = *new Kolonia();
- for(int i=0; i<26; i++) {
- elsoKolonia+=elsoTelepesek[i];
- const Telepes* ittLakok;
- ittLakok= elsoKolonia.get_lakok();
- cout << ittLakok[i].get_bolygo() + "és" + elsoTelepesek[i].get_bolygo()<< endl;
- }
- cout<< ~elsoKolonia ? "VEGÁN KOLÓNIA" : "NEM VEGÁN KOLÓNIA";
- return 0;
- }
- Kolonia::Kolonia() : nev(""), bolygo(""), letszam(0) {
- lakok = new Telepes[25];
- }
- Kolonia::Kolonia(const string &nev, const string &bolygo) : nev(nev), bolygo(bolygo), letszam(0) {
- lakok = new Telepes[25];
- }
- const string &Kolonia::get_nev() const {
- return nev;
- }
- void Kolonia::set_nev(const string &nev) {
- Kolonia::nev = nev;
- }
- const string &Kolonia::get_bolygo() const {
- return bolygo;
- }
- void Kolonia::set_bolygo(const string &bolygo) {
- Kolonia::bolygo = bolygo;
- }
- unsigned int Kolonia::get_letszam() const {
- return letszam;
- }
- const Telepes* Kolonia::get_lakok() const {
- return lakok;
- }
- Telepes::Telepes(){
- nev="";
- szul_bolygo="";
- bolygo="";
- ero=1;
- vegan=false;
- }
- const string &Telepes::get_nev() const {
- return nev;
- }
- void Telepes::set_nev(const string &toBeNev) {
- Telepes::nev = toBeNev;
- }
- const string &Telepes::get_szul_bolygo() const {
- return szul_bolygo;
- }
- void Telepes::set_szul_bolygo(const string &szulBolygo) {
- szul_bolygo = szulBolygo;
- }
- const string &Telepes::get_bolygo() const {
- return bolygo;
- }
- void Telepes::set_bolygo(const string &toBeBolygo) {
- Telepes::bolygo = toBeBolygo;
- }
- unsigned int Telepes::get_ero() const {
- return ero;
- }
- void Telepes::set_ero(unsigned const int toBeEro) {
- Telepes::ero = toBeEro;
- }
- bool Telepes::is_vegan() const {
- return Telepes::vegan;
- }
- void Telepes::set_vegan(const bool &toBeVegan) {
- Telepes::vegan = toBeVegan;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement