Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Note: I am coding in C++ Consider an animal shelter that contains two types of animals: dogs and cats. A dog is represented by the

image text in transcribed

Note: I am coding in C++

Consider an animal shelter that contains two types of animals: dogs and cats. A dog is represented by the Dog class, a cat is represented by a cat class, and both classes inherit the Animal class. The animal shelter maintains a singly list of all the animals (nodes with an Animal * pointer that points to the Animal) When you want to adopt an animal from this shelter, you let them know your preference for a dog, cat, or either. Based on your preference, you adopt the animal closest to the head of the list that matches your preference. In the List class, complete the adoptCat, adoptDog, and adoptAny member function in list.cpp. Each of these functions must: 1. find the animal closest to the head of the list that meets the function preferences (if a suitable animal exists), 2. remove that node from the list, and 3. return a pointer to the Animal (if a suitable animal was found) or NULL if no animal was found Reference The List class (list.cpp, list.h) stores a singly linked list of ListNode nodes, using the same structure and variable names as MP3. The Animal class has a member function getType() that will return "Dog" or "Cat" based on the type of animal. Compile and Test A complete Makefile and tester code is provided for you. To compile and test, run: make ./animal-test

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_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

Database Principles Programming And Performance

Authors: Patrick O'Neil

1st Edition

1558603921, 978-1558603929

Students also viewed these Databases questions

Question

Strengthen your personal presence.

Answered: 1 week ago

Question

What about leadership lessons from particularly good or bad bosses?

Answered: 1 week ago

Question

What does Processing of an OLAP Cube accomplish?

Answered: 1 week ago