Answered step by step
Verified Expert Solution
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
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-testStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started