Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Q1 Write a class called Vector3D which contains three private float variables. Your class should contain the following: 1. Default Constructor. 2. Parameterized Constructor.

C++

Q1

Write a class called Vector3D which contains three private float variables. Your class should contain the following:

1. Default Constructor.

2. Parameterized Constructor.

3. Copy Constructor.

4. Write corresponding setters and getters.

5. Overload the operator += and operator -= to allow addition and subtraction.

Q2

Write a Class ZooAnimal that contains the following private variables: name, cage number, age, food, and sleeping hours.

The ZooAnimal class contains two functions: sleep() and eat(). The sleep function takes the average sleeping hours of the animal as an input and prints it to the user. The eat() function takes the favorite food of the animal and an amount and prints the amount consumed by the animal to the user in pounds.

The ZooAnimal class should have setters and getters for the private variables: name, cage number, and age. Use this class to derive three child classes: elephant, lion, snake. For each of the child classes add the following private variables when applicable: number of legs, tail, length (ex. A snake cannot have a number of legs variable). define the setters and getters for the newly added variables.

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

Professional SQL Server 2012 Internals And Troubleshooting

Authors: Christian Bolton, Justin Langford

1st Edition

1118177657, 9781118177655

More Books

Students also viewed these Databases questions