Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

MySQL Crash Course A Hands On Introduction To Database Development

Authors: Rick Silva

1st Edition

1718503008, 978-1718503007

More Books

Students also viewed these Databases questions

Question

What are advantages and disadvantages of Just in Time Inventory?

Answered: 1 week ago

Question

a sin(2x) x Let f(x)=2x+1 In(be)

Answered: 1 week ago