C++ programing. In nature, scientists have determined there are two types of bees: friendly bees and mean bees. A friendly bee will only sting a mean person if they refuse to become nice when asked and will never sting people that are not mean. On the other hand, a mean bee stings everyone. Given the following classes, main and sample run, create classes that represent these bees. Use the given Bee class. class Person{ public: bool mean; //true means they are mean, false they are not mean bool stung; //true means they got stung, false means they did not get stung Person(bool mean) { this->mean=mean; stung=false; //all people start out not being stung } }; Main (sample run below): int main(int argc, char** argv){ Person p(true); Person p2(false); Person p3(true); class Bee{ public: virtual bool sting(Person &p)=0; }; Person p4(false); cout<<"p: mean-"<
C++ programing.
In nature, scientists have determined there are two types of bees: friendly bees and mean bees. A friendly bee will only sting a mean person if they refuse to become nice when asked and will never sting people that are not mean. On the other hand, a mean bee stings everyone.
Given the following classes, main and sample run, create classes that represent these bees. Use the given Bee class.
class Person{ public:
bool mean; //true means they are mean, false they are not mean
bool stung; //true means they got stung, false means they did not get stung
Person(bool mean)
{
this->mean=mean;
stung=false; //all people start out not being stung
} };
Main (sample run below):
int main(int argc, char** argv){ Person p(true);
Person p2(false);
Person p3(true);
class Bee{
public:
virtual bool sting(Person &p)=0;
};
Person p4(false);
cout<<"p: mean-"<<p.mean<<", stung-"<<p.stung<<endl; cout<<"p2: mean-"<<p2.mean<<", stung-"<<p2.stung<<endl; cout<<"p3: mean-"<<p3.mean<<", stung-"<<p3.stung<<endl; cout<<"p4: mean-"<<p4.mean<<", stung-"<<p4.stung<<endl;
Friendly_bee b1; Mean_bee b2;
b1.sting(p); b1.sting(p2);
b2.sting(p3); b2.sting(p4);
cout<<"p: mean-"<<p.mean<<", stung-"<<p.stung<<endl; cout<<"p2: mean-"<<p2.mean<<", stung-"<<p2.stung<<endl; cout<<"p3: mean-"<<p3.mean<<", stung-"<<p3.stung<<endl; cout<<"p4: mean-"<<p4.mean<<", stung-"<<p4.stung<<endl;
}
Sample Run:
p: mean-1, stung-0 //mean is 1 (true), not mean is 0 (false)...stung is 0 for all (false) p2: mean-0, stung-0
p3: mean-1, stung-0
p4: mean-0, stung-0
-----
Friendly bee says: Hello! :) If you stop being mean, I won't sting you. Will you stop being mean? no
Friendly bee says: Sorry, but then I have no choice but to sting you! :(
-----
Friendly bee says: Hello! :) You're not mean, so I won't sting you!
-----
Mean bee says: You're mean like me...so you understand that I have to sting you!
-----
Mean bee says: Sorry, but I have to sting you even if you are nice...
p: mean-1, stung-1 //Notice that some people are now stung (1-they got stung and the modification is shown) p2: mean-0, stung-0
p3: mean-1, stung-1
p4: mean-0, stung-1
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 5 images