Subject Computer Science C-Family Programming


1) Using C++ classes and virtual methods, organize the animals in a small zoo, having as guests lions, parrots, alligators, penguins, elephants, cobras, zebras, hawks, turkeys and rabbits.
Use at least 3 properties some of the animals might share and demonstrate overriding of their getter and setter methods.
Write 10 examples of method calls asking the inhabitants of the zoo to perform tasks to which they would answer back either "Doing it!" or "Sorry, I cannot do it".
**Must comment before beginning a function explaining what the underlying function is going to do*
**Program cannot come from internet sources**

Solution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

#include <cstdlib>
#include "alligators.h"
#include "animal.h"
#include "cobras.h"
#include "elephants.h"
#include "hawks.h"
#include "lions.h"
#include "parrots.h"
#include "penguins.h"
#include "rabbits.h"
#include "turkeys.h"
#include "zebras.h"
using namespace std;

int main(int argc, char** argv) {

    // create 10 pointer
    //    in order to assign and all child class
    // we always use pointer
    animal * a[10];
    // assing the newly created object to pointers
    a[0] = new alligators("dark green",100,5);
    a[1] = new cobras("black yellow",6,3);
    a[2] = new elephants("grey",1000,8);
    a[3] = new hawks("brown",2,1);
    a[4] = new lions("yellow",500,3);
    a[5] = new parrots("green red yellow blue",1,1);
    a[6] = new penguins("black white", 2,2);
    a[7] = new rabbits("white pink", 2, 1);
    a[8] = new turkeys("black red",3,2);
    a[9] = new zebras("white black",90,3);

This is only a preview of the solution. Please use the purchase button to see the entire solution

Assisting Tutor

Related Homework Solutions

Get help from a qualified tutor
Live Chats