Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For this assignment you will be tasked with creating several classes In C++. 3 abstract classes and 3 concrete classes. The base class will be

For this assignment you will be tasked with creating several classes In C++. 3 abstract classes and 3 concrete classes. The base class will be class Animal. This will be an abstract class following are its required specifications

public static variable count that counts number of animals created

default constructor that adds one to the count.

pure virtual function speak() that returns a string.

There will be an class Canine. It inherits from Animal.

public static variable, count, that counts number of Canines created.

default constructor that adds one to the count.

implement the speak() to return string WOOF.

There will be an class Feline. It also inherits from Animal.

public static variable, count, that counts number of Felines created

default constructor that adds one to the count.

implement the speak() to return string PURR.

There will be a class Dog. It inherits from Canine.

private string variable called name.

default constructor that sets the name variable to dog.

constructor that takes a single string parameter and sets that parameter as the name.

getName function that returns the name of the Dog.

There will be a class Wolf. It inherits from Canine.

default constructor that is empty.

howl function that returns a string HOWL.

There will be a class Cat. It inherits from Feline.

private string variable called name.

default constructor that sets the name variable to cat.

constructor that takes a single string parameter and sets the parameter as the name.

getName function that returns the name of the Cat.

Some things to note:

Note there is no setName function. This is intentional. The logic is that a Dog/Cats name is set only once and will never be changed

. Please note that base class default constructors are called before the beginning of a derived classs constructor.

This means you only need to handle static counts for their respective classes (so you do not have to worry about Animal count from the Canine class).

Please also create a main.cpp file that will test the following:

Create a Dog, Wolf and Cat, using only default constructors.

Create a Dog and Cat with a name.

Create an Animal * array and instantiate and store at least a Dog, a Cat and a Wolf.

Use for loop to call speak on each of the animals stored in Animal array.

Call howl function.

Show all counts for Animal, Canine and Feline

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

Databases On The Web Designing And Programming For Network Access

Authors: Patricia Ju

1st Edition

1558515100, 978-1558515109

More Books

Students also viewed these Databases questions

Question

measure the success or otherwise of events;

Answered: 1 week ago