0% found this document useful (0 votes)
8 views

Lab: Zoo Management System Code

zoo code

Uploaded by

aleesha waqar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Lab: Zoo Management System Code

zoo code

Uploaded by

aleesha waqar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Name: Aleesha Waqar

Class: BEE-14A

School: SEECS

CMS: 417349

Instructor: mam Ayesha Sarwar

Lab instructor : Mehvish kiran

Lab : zoo management system


Code:
#include <iostream>

#include <vector>

#include <string>

using namespace std;

class Animal {

public:

string name;

int age;

string species;

int health_status;

int happiness;

Animal(const string& name, int age, const string& species, int health_status, int happiness)

: name(name), age(age), species(species), health_status(health_status), happiness(happiness) {}

void feeding() {

health_status++;
happiness++;

void playing() {

happiness++;

void medical_care() {

health_status++;

happiness++;

};

class Lion : public Animal {

public:

int power;

int roar;

Lion(const string& name, int age, int health_status, int happiness, int power, int roar)

: Animal(name, age, "Lion", health_status, happiness), roar(roar), power(power) {}

};

class Elephant : public Animal {

public:

int trumpets;

int weight;

Elephant(const string& name, int age, int health_status, int happiness, int trumpets, int weight)

: Animal(name, age, "Elephant", health_status, happiness), trumpets(trumpets), weight(weight) {}

};
class Giraffe : public Animal {

public:

int neck;

int weight;

Giraffe(const string& name, int age, int health_status, int happiness, int neck, int weight)

: Animal(name, age, "Giraffe", health_status, happiness), neck(neck), weight(weight) {}

};

class Enclosure {

public:

string name;

int size;

vector<Animal> animals;

vector<string> enrichmentActivities;

Enclosure(const string& name, int size) : name(name), size(size) {}

void addAnimal(const Animal& animal) {

animals.push_back(animal);

void addEnrichmentActivity(const string& activity) {

enrichmentActivities.push_back(activity);

};

class Zoo {

public:

vector<Enclosure> enclosures;
vector<string> visitorFeedback;

void addEnclosure(const Enclosure& enclosure) {

enclosures.push_back(enclosure);

int getTotalNumberOfAnimals() {

int totalAnimals = 0;

for (const Enclosure& enclosure : enclosures) {

totalAnimals += enclosure.animals.size();

return totalAnimals;

void addVisitorFeedback(const string& feedback, int rating) {

string feedbackWithRating = "Rating: " + to_string(rating) + " - " + feedback;

visitorFeedback.push_back(feedbackWithRating);

void scheduleEvent(const string& eventName, const string& date, const string& time, const
vector<Animal>& animals) {

cout << "Scheduled Event: " << eventName << " on " << date << " at " << time << endl;

cout << "Participating Animals:" << endl;

for (const Animal& animal : animals) {

cout << animal.name << " (" << animal.species << ")" << endl;

void feedAnimals(const vector<Animal>& animals) {


for (const Animal& animal : animals) {

Animal& nonConstAnimal = const_cast<Animal&>(animal);

nonConstAnimal.feeding();

void provideMedicalCare(const vector<Animal>& animals) {

for (const Animal& animal : animals) {

Animal& nonConstAnimal = const_cast<Animal&>(animal);

nonConstAnimal.medical_care();

void addEnrichmentActivity(Enclosure& enclosure, const string& activity) {

enclosure.addEnrichmentActivity(activity);

};

class Zookeeper {

public:

string name;

vector<Animal> assignedAnimals;

Zookeeper(const string& name) : name(name) {}

void feedAnimals() {

for (Animal& animal : assignedAnimals) {

animal.feeding();

}
}

void provideMedicalCare() {

for (Animal& animal : assignedAnimals) {

animal.medical_care();

};

int main() {

// Create animals

Lion simba("Simba", 5, 90, 70, 10, 8);

Elephant dumbo("Dumbo", 8, 95, 75, 5, 3000);

Giraffe melman("Melman", 7, 88, 80, 14, 1200);

// Create enclosures

Enclosure lionEnclosure("Lion Enclosure", 1000);

Enclosure elephantEnclosure("Elephant Enclosure", 2000);

Enclosure giraffeEnclosure("Giraffe Enclosure", 1500);

// Add animals to enclosures

lionEnclosure.addAnimal(simba);

elephantEnclosure.addAnimal(dumbo);

giraffeEnclosure.addAnimal(melman);

// Add enrichment activities to enclosures

lionEnclosure.addEnrichmentActivity("Hide and Seek");

elephantEnclosure.addEnrichmentActivity("Water Sprinkles");

giraffeEnclosure.addEnrichmentActivity("Tall Tree Branches");


// Create zoo

Zoo myVirtualZoo;

// Add enclosures to the zoo

myVirtualZoo.addEnclosure(lionEnclosure);

myVirtualZoo.addEnclosure(elephantEnclosure);

myVirtualZoo.addEnclosure(giraffeEnclosure);

// Assign zookeepers to enclosures

Zookeeper john("John");

john.assignedAnimals.push_back(simba);

Zookeeper michael("Michael");

michael.assignedAnimals.push_back(dumbo);

michael.assignedAnimals.push_back(melman);

// Schedule events

vector<Animal> lionEventAnimals = { simba };

vector<Animal> elephantEventAnimals = { dumbo };

vector<Animal> giraffeEventAnimals = { melman };

myVirtualZoo.scheduleEvent("Lion Show", "2023-10-15", "15:00", lionEventAnimals);

myVirtualZoo.scheduleEvent("Elephant Parade", "2023-10-16", "10:30", elephantEventAnimals);

myVirtualZoo.scheduleEvent("Giraffe Feeding", "2023-10-17", "11:45", giraffeEventAnimals);

// Feed animals

myVirtualZoo.feedAnimals(john.assignedAnimals);

myVirtualZoo.feedAnimals(michael.assignedAnimals);
// Provide medical care

myVirtualZoo.provideMedicalCare(john.assignedAnimals);

myVirtualZoo.provideMedicalCare(michael.assignedAnimals);

// Display the total number of animals in the zoo

int totalAnimals = myVirtualZoo.getTotalNumberOfAnimals();

cout << "Total number of animals in the zoo: " << totalAnimals << endl;

return 0;

Output:

You might also like