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
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