Skip to main content
Loading...

More C++ Posts

#include "goat.h" //include goat.h

void Goat::setBreed(string breed) {
   this->breed = breed;
}
void Goat::setWeight(float weight) {
   this->weight = weight;
}
void Goat::setName(string name) {
   this->name = name;
}
void Goat::setGender(char gender) {
   this->gender = gender;
}
void Goat::setSpayed(bool goatIsSpayed) {
   this->goatIsSpayed = goatIsSpayed;
}
void Goat::setRegistrationID(string registrationID) {
   this->registrationID = registrationID;
}
void Goat::setColor(string color) {
   this->color = color;
}
void Goat::setOtherComments(string otherComments) {
   this->otherComments = otherComments;
}
string Goat::getBreed() {
   return breed;
}
float Goat::getWeight() {
   return weight;
}
string Goat::getName() {
   return name;
}
char Goat::getGender() {
   return gender;
}
bool Goat::getSpayed() {
   return goatIsSpayed;
}
string Goat::getRegistrationID() {
   return registrationID;
}
string Goat::getColor() {
   return color;
}
string Goat::getOtherComments() {
   return otherComments;
}

Goat::Goat() {
   breed = "";
   weight = 0.0;
   name = "";
   gender = '\0';
   goatIsSpayed = false;
   registrationID = "";
   color = "";
   otherComments = "";
}

Goat::Goat(string goatBreed, float goatWeight, string goatName, char goatGender, bool goatSpayedStatus, string goatRegistrationID, string goatColor, string goatOtherComments) {
  
   breed = goatBreed;
   weight = goatWeight;
   name = goatName;
   gender = goatGender;
   goatIsSpayed = goatSpayedStatus;
   registrationID = goatRegistrationID;
   color = goatColor;
   otherComments = goatOtherComments;
}

Goat::~Goat() {
   cout << "goat destroyed" << endl;
}

void Goat::printinfo() {  
   cout << "Breed: " << breed << endl << "weight: " << weight << endl << "Name: " << name << endl << "Gender: " << gender << endl << "is Spayed: ";
   if(goatIsSpayed) {  //here I do a logical test on boolean goatIsSpayed. if true cout << true else cout << false
      cout << "True";
   } else {
      cout << "False";
   }
   cout << endl << "Registration ID: " << registrationID << endl << "Color Description: " << color << endl << "Other Comments: " << otherComments << endl << endl;
}