#include using namespace std;
struct AnimalInfo {
string tagNum, feedType;
float animalWeight, animalAge, dailyFeedAmount;
bool isVaccinated;
};
enum class animalHealthStatus { Injured = 1, Sick = 2, Healthy = 3 };
class FarmAnimal {
protected:
AnimalInfo animalInfo;
animalHealthStatus status;
bool isVaccinated;
public:
FarmAnimal() {
animalInfo = {"", "", 0.0, 0.0, 0.0, false};
status = animalHealthStatus::Healthy;
isVaccinated = false;
}
void setAnimalDetails(string TagID,string feedType, float dailyFeedAmount, float weight, float age, animalHealthStatus s, bool isVaccinated) {
animalInfo.tagNum = TagID;
animalInfo.feedType = feedType;
animalInfo.dailyFeedAmount = dailyFeedAmount;
animalInfo.animalWeight = weight;
animalInfo.animalAge = age;
status = s;
isVaccinated = false;
};
//getters
string getTagNumber() {
return animalInfo.tagNum;
}
float getWeight() {
return animalInfo.animalWeight;
}
float getAge() {
return animalInfo.animalAge;
}
animalHealthStatus getHealth() {
return status;
}
bool getVaccinationStatus() {
return isVaccinated;
}
string getFeedType() {
return animalInfo.feedType;
}
float getDailyFeedAmount() {
return animalInfo.dailyFeedAmount;
};
void displayAnimalDetails() {
cout << "Details" << endl;
cout << " Tag Number: " << getTagNumber() << endl;
cout << " Weight: " << getWeight() << " kg" << endl;
cout << " Age: " << getAge() << " years" << endl;
cout << " Feed Type: " << getFeedType() << endl;
cout << " Daily Feed Amount: " << getDailyFeedAmount() << " kg/day" << endl;
switch (status) {
case animalHealthStatus::Injured:
cout << " Health Status: Injured" << endl;
break;
case animalHealthStatus::Sick:
cout << " Health Status: Sick" << endl;
break;
case animalHealthStatus::Healthy:
cout << " Health Status: Healthy" << endl;
break;
}
cout << " Vaccination Status: " << (getVaccinationStatus() ? "Vaccinated" : "Not Vaccinated") << endl;
}
};
class Pigs : public FarmAnimal { protected: string pigBreed, pigSpecies; bool isPregnant; float dailyManureProduction;
public:
// constructor to initialize pig attributes
Pigs() {
pigBreed = "";
pigSpecies = "";
isPregnant = false;
dailyManureProduction = 0.0;
}
string getPigSpecies() {
return "Pig";
}
string getPigBreed() {
return pigBreed;
}
bool getIsPregnant() {
return isPregnant;
}
float getDailyManureProduction() {
return dailyManureProduction;
}
void setPigDetails(string species, string breed, bool pregnant, float manureProduction) {
pigSpecies = species;
pigBreed = breed;
isPregnant = pregnant;
dailyManureProduction = manureProduction;
};
void inputPigDetails() {
cout <<"Enter pig breed: ";
cin >> pigBreed;
cout << "Is the pig pregnant? (1 for Yes, 0 for No): ";
cin >> isPregnant;
cout << "Enter daily manure production [kg/day]: ";
cin >> dailyManureProduction;
};
void displayPigDetails() {
cout << " Pig Species: " << getPigSpecies() << endl;
cout << " Pig Breed: " << getPigBreed() << endl;
cout << " Pregnancy: " << (getIsPregnant() ? "Yes" : "No") << endl;
cout << " Daily Manure Production: " << getDailyManureProduction() << " kg/day" << endl;
}
};
class Cattle : public FarmAnimal {
protected:
string cattleBreed, cattleSpecies;
bool isMilking, isPregnant;
float dailyMilkProduction;
public:
// constructor to initialize cattle attributes
Cattle() {
cattleBreed = "";
cattleSpecies = "";
isMilking = false;
isPregnant = false;
dailyMilkProduction = 0.0;
}
string getCattleSpecies() {
return "Cattle";
}
string getCattleBreed() {
return cattleBreed;
}
bool getIsMilking() {
return isMilking;
}
bool getIsPregnant() {
return isPregnant;
}
float getDailyMilkProduction() {
return dailyMilkProduction;
}
void setCattleDetails(string species, string breed, bool milking, bool pregnant, float milkProduction) {
cattleSpecies = species;
cattleBreed = breed;
isMilking = milking;
isPregnant = pregnant;
dailyMilkProduction = milkProduction;
};
void inputCattleDetails() {
cout << "Enter cattle breed: ";
cin >> cattleBreed;
cout << "Is the cattle milking? (1 for Yes, 0 for No): ";
cin >> isMilking;
cout << "Is the cattle pregnant? (1 for Yes, 0 for No): ";
cin >> isPregnant;
cout << "Enter daily milk production [liters/day]: ";
cin >> dailyMilkProduction;
};
void displayCattleDetails() {
cout << " Cattle Species: " << getCattleSpecies() << endl;
cout << " Cattle Breed: " << getCattleBreed() << endl;
cout << " Milking: " << (getIsMilking() ? "Yes" : "No") << endl;
cout << " Pregnancy: " << (getIsPregnant() ? "Yes" : "No") << endl;
cout << " Daily Milk Production: " << getDailyMilkProduction() << " liters/day" << endl;
}
};
void inputAnimalDetails(FarmAnimal& animal) {
string tagnum, feedType;
float weight, age, dailyFdAmount;
int healthStatus;
cout << "Enter livestock tag number: ";
cin >> tagnum;
cout << "Enter Feed Type: ";
cin >> feedType;
cout << "Enter daily feed amount [kg/day]: ";
cin >> dailyFdAmount;
cout << "Enter animal weight [kg]: ";
cin >> weight;
cout << "Enter age [years]: ";
cin >> age;
cout << "Enter health status: 1. Injured , 2. Sick , 3. Healthy: ";
cin >> healthStatus;
cout << "Is the animal vaccinated? (1 for Yes, 0 for No): ";
bool isVaccinated;
cin >> isVaccinated;
animal.setAnimalDetails(tagnum, feedType, dailyFdAmount, weight, age, static_cast<animalHealthStatus>(healthStatus), isVaccinated);
};
int main () {
Pigs pig1;
pig1.inputPigDetails();
inputAnimalDetails(pig1);
pig1.displayAnimalDetails();
pig1.displayPigDetails();
/* Cattle cattle1;
inputAnimalDetails(cattle1);
cattle1.inputCattleDetails();
cattle1.displayAnimalDetails();
cattle1.displayCattleDetails();
*/
return 0;
}