1+1=3 Like family and breeding, I get idea to test my new skills on this subject
#include
using namespace std;
class Pulsu {
public:
int Afterbreed;
int BreedingRate;
Pulsu () {};
Pulsu (int x, int y){Afterbreed=x; BreedingRate=y;}
Pulsu operator + (const Pulsu&);
};
Pulsu Pulsu::operator+ (const Pulsu& p) {
Pulsu temp;
//temp.BreedingRate=(BreedingRate+p.BreedingRate)/2;
if((BreedingRate+p.BreedingRate)%2==0){
temp.BreedingRate=int ((BreedingRate+p.BreedingRate)/2);
}else{
temp.BreedingRate=int ((BreedingRate+p.BreedingRate+1)/2);//I notice these must alter to int or else //error
//it is not int if like 3/2
}
if( (Afterbreed-p.Afterbreed)<=0){
temp.Afterbreed =(Afterbreed*2)+ (Afterbreed*temp.BreedingRate) -(Afterbreed-p.Afterbreed);
}else{
temp.Afterbreed =(p.Afterbreed*2)+(Afterbreed*temp.BreedingRate) +(Afterbreed-p.Afterbreed);
}
return temp;
}
int main () {
Pulsu Ratfemales={22,0};//22 is how many and 0 is breedinrate
Pulsu Ratmales={15,3};
Pulsu Ratfamily;
Ratfamily=Ratmales+Ratfemales;
cout << Ratfamily.Afterbreed <<'\n' ;
return 0;
}
Yes! and it was no 1+1 but 22+15 and breeding rate 0 and 3
No comments:
Post a Comment