Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A header file Zoo.h will be provided to you. All the variables are explained in the file. Zoo.cpp contains all the definition of the functions.

A header file Zoo.h will be provided to you. All the variables are explained in the file. Zoo.cpp contains all the definition of the functions. Details of the functions are provided in that fille. Please read it carefully. Please note that there are two additional header files added. You can use them or add new according to your needs.

Use C++ code (Solve full problem with code, not explanation) I am Posting this question twice. Previous expert can't solve the problem properly)

Again said, Solve the problem using Code, No bla bla explanation, I um just copy your code and paste it. Thanqs for understand.

Task 01 Imagine there are 3 Zoos at the locations (co-ordinates): (13,17), (28,2), (7,14) with the following population- zoo_

Task 04 Modify the Zoo.cpp file in the following manner: 1. Print which of the 3 zoos has the most number of animals. 2. If m

Please Do Task 04

I am adding task 01 just because for your help to do solve the problem easier.

Now I am adding zoo.h and zoo.cpp file Accordingly....

Zoo.h

#ifndef ZOO_H_INCLUDED
#define ZOO_H_INCLUDED
#include <iostream>

/*
Variables Explanation
===============================================+==========
--totalNoOfAnimal Total number of Animals
--NoOfUniqueAnimal Number of Unique animals
--xcordinate Co-ordinate of the Zoo along x-axis
--ycordinate Co-ordinate of the Zoo along y-axis

--animals [1000] Stores name of Unique animals
--noOfAnimalsEach[1000] Stores number of animals exists
*/

class Zoo
{
private:
int totalNoOfAnimal, NoOfUniqueAnimal, xcordinate, ycordinate;
std::string animals [1000];
int noOfAnimalsEach [1000];
public:
Zoo(int, int, int);
~Zoo();
void setValue(std::string, int, int);
int getNoanimalExist(int);
int getAnimalIndex(std::string);
};

#endif // ZOO_H_INCLUDED

------------------------------------------------------------------

Zoo.cpp

#include "Zoo.h"
#include <iostream>
#include<string>
#include<math.h>

using namespace std;


Zoo::Zoo (int u, int a, int b) //Constructor
{
xcordinate = a;
ycordinate = b;
totalNoOfAnimal=0;
NoOfUniqueAnimal = u;
animals [u];
noOfAnimalsEach[u];
}

Zoo::~Zoo() //Destructor
{
totalNoOfAnimal = NULL;
NoOfUniqueAnimal = NULL;
}

void Zoo:: setValue(string s, int x, int index) //This function populates the zoo.
{
animals [index]= s;
noOfAnimalsEach[index]= x;
totalNoOfAnimal+=x;
}

int Zoo::getAnimalIndex(string name)//This function returns the index for each animal in the array. '-1' indicates when animals are not found.
{
int i=0;
while (i< NoOfUniqueAnimal+1 && animals[i]!=name){i++;}
if (i<NoOfUniqueAnimal+1) return i;
else return -1;
}

int Zoo:: getNoanimalExist(int index)//This function returns the number of animals exists for each unique animal in the 'animals' array by index.
{
if(index>=0) return noOfAnimalsEach[index];
else cout<< "Does not exist!"<< endl;
}
 

Task 01 Imagine there are 3 Zoos at the locations (co-ordinates): (13,17), (28,2), (7,14) with the following population- zo0_01 zoo_02 zoo_03 Animal List Quantity Animal List Quantity Animal List Quantity Tiger 4 Tiger Tiger Lion Lion Lion Elephant Deer 3. Deer Zebra 2 Zebra 4 Zebra Deer 7 Crocodile Crocodile 3 Crocodile 10 Monkey 25 Turtles 25 Snake 20 Elephant 2 Birds 15 1 Now create the 3 Zoos accordingly. Make sure to give them unique names.

Step by Step Solution

3.48 Rating (148 Votes )

There are 3 Steps involved in it

Step: 1

Answer include using namespace std Variables Explanation totalNoOfAnimal Total number of Animals NoO... 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_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

Basic Business Statistics Concepts And Applications

Authors: Mark L. Berenson, David M. Levine, Timothy C. Krehbiel

12th Edition

132168383, 978-0132168380

More Books

Students also viewed these Computer Engineering questions