Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using C++ Task 1: Create a base Animal Class using C++ - Design a class to abstractly model animals. You may want to read the

Using C++

Task 1: Create a base Animal Class using C++

- Design a class to abstractly model animals. You may want to read the entire assignment before starting this task.

- Include at least 2 attributes along with getters and setters for the attributes.

- Create a default constructor and an overload constructor allowing you to set values for all attributes.

- Define a virtual function called move. Define a non-virtual function called eat that prints out the string Yummy!.

- Create the implementation code for the above functions as required.

Give a short explanation how each member will be available in derived classes (i.e. not available, available if not overridden, etc)

THEN: Create 2 classes that inherit from this class.

- Create a class for fish and horse that inherits from Animal.

- Fish should have the following features:

- Move should be defined as printing out Just keep swimming.

- Eat should be defined as printing out Yummy Fish Food.

- Add 1 additional attribute to the fish class. Include a getter and setter.

- Horse should have the following features:

- Move should be defined as printing out Walk, Trot, Canter, Gallop.

- Eat should be defined as printing out Yummy grass.

- Add 1 additional attribute for the horse class (different from the fish class). Include a getter and setter.

Describe what version of the derived class members will be available in instances of the derived class and in instances of the derived class declared as the base class type.

THEN: Create a program that tests the classes.

Prompt the user for which class to create and values to set the attributes for that class. Include the option to create a fish or horse as an animal. This may look like:

Press 1 for an instance of animal.

Press 2 for an instance of fish.

Press 3 for an instance of horse.

Press 4 for an instance of a fish declared as an animal

Press 5 for an instance of a horse declared as an animal

Call the move and eat functions from the instance created in step a.

Create a function outside of classes that accepts an animal as a parameter. This function should call the move and eat function of the input parameter.

Call the function from step c.

Ask the user if they wish to continue. If so, loop to step a.

Use your test program to test all member functions and ensure the class is working correctly.

Include a screen shot of the output. How did the actual results compare to expected results from task 2;

Greatly Appreciate Any Help

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

Step: 3

blur-text-image

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

The Database Experts Guide To Database 2

Authors: Bruce L. Larson

1st Edition

0070232679, 978-0070232679

More Books

Students also viewed these Databases questions

Question

2. Place a value on the outcomes.

Answered: 1 week ago