Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Main.cpp #include Animal.h #include int main() { std::vector animals; int num; std::cout > num; for(int i = 0; i > name; std::cout > id_number; std::cout

image text in transcribedimage text in transcribed

Main.cpp

#include "Animal.h" #include

int main() { std::vector animals; int num; std::cout > num; for(int i = 0; i > name; std::cout > id_number; std::cout > gender; std::cout > age; std::cout > health_status; animals.push_back(Animal(name, id_number, gender, age, health_status)); } for(Animal a : animals) std::cout

Animal.h

#include #include

class Animal { public: Animal(std::string n = "John Doe", int id = 0, bool g = 0, int a = 1, std::string hs = "healthy") : name(n), id_number(id), gender(g), age(a), health_status(hs) {}; std::string get_name() const; int get_id_number() const; bool get_gender() const; int get_age() const; std::string get_health_status() const; void set_name(std::string); void set_id_number(int); void set_gender(bool); void set_age(int); void set_health_status(std::string); std::string to_string() const; friend std::ostream& operator

#include "Animal.h"

std::string Animal::get_name() const { return name; }

int Animal::get_id_number() const { return id_number; }

bool Animal::get_gender() const { return gender; }

int Animal::get_age() const { return age; }

std::string Animal::get_health_status() const { return health_status; }

void Animal::set_name(std::string n) { name = n; }

void Animal::set_id_number(int id) { id_number = id; }

void Animal::set_gender(bool g) { gender = g; }

void Animal::set_age(int a) { age = a; }

void Animal::set_health_status(std::string hs) { health_status = hs; }

std::string Animal::to_string() const { std::ostringstream oss; oss

std::ostream& operator

anges to Animal Class First, there are some minor changes to the Animal Class. New private variable called type. This tells us what type of animal it is (lion, snake, etc) Accessor and Mutator function for type Operator: function that returns true if the id-numbers of two different Animals are the same Else it returns false The Zoo class Second you will create two C++ files called abc1234_Zoo.h and abc1234_Zoo.cpp Each pair in the map represents an exhibit in a zoo. The first element says what type of exhibit it is (such as the lion exhibit, or the bird exhibit). The second element is a vector containing all the animals in that exhibit. The capacity number is how many animals the zoo can hold The default constructor assigns a default number to the amount of animals the zoo can hold (you decide) The other constructor assigns the zoo's capacity to the input parameter. Get and Set capacity are basic accessor and mutator functions . add_animal first checks to see if the zoo is at capacity. If we cannot add the animal, we return false. If we can, when check all animals' id_numbers. If there is a duplicate id_number of the animal we are trying to add, return false. Else, we then see if we already have an exhibit for that type of animal. If we do not, we add a new pair to the map. Then we check the list to see if that animal is already in the list by using theoperator. If it is, we return false. Else, we add it to the list and return true get_animals_of_type returns a vector (missing from UML) of the list of animals in that exhibit. is_animal_in_zoo returns true if the animal is in the zoo. Else, return false. Note, the only input parameter you have for this function is the id_number remove_animal removes the animal from the zoo. Note, the only input parameter you have for this function is the id_number. change_animal_age will change the animal's age with the matching id_number to the age in the input parameter change_animal_health_status will change the animal's health_status with the matching . remove_animal removes the animal from the zoo. Note, the only input parameter you have for . change_animal_age will change the animal's age with the matching id_number to the age in the change_animal_health_status will change the animal's health_status with the matching parameter you have for this function is the id_number. this function is the id_number. input parameter. id_number to the health_status in the input parameter. operator

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions