Question: SET-252 C Programming #2 Homework: 3 Introduction to classes, encapsulation and inheritance Step 1 Basic class and encapsulation Create a CDog class using the attached

SET-252 C Programming #2

Homework: 3 Introduction to classes, encapsulation and inheritance

Step 1 Basic class and encapsulation

Create a CDog class using the attached class file template.

Add two private properties: m_strName, m_sngWeight.

Create public get/set methods for each property. Be sure to boundary check in the ALL set methods.

Create a public Bark method. Inside the Bark method print "Yip, yip, yip" if the dog's weight is less than 15.0f. Print "Woof, woof" if the dog's weight is greater than or equal to 15.0f.

Step 2 Inheritance

Create a CTrainedDog class that inherits CDog.

Add a public Fetch method that prints something like "Fetching the tasty stick. ".

Add a public PlayDead method with something similar to Fetch.

Step 3 Test

Make a Homework3.cpp file add a main function and in the main function declare a variable of type CDog and CTrainedDog. Write code that demonstrates encapsulation and inheritance (i.e. call the methods).

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!