View the step-by-step solution to:

Question

Exercise

"

We have the following 5 classes:


Base

Class: Canidae

Derived from Canidae: Fox, Wolf

Derived from Fox: Red Fox

Derived from Wolf : Gray Wolf


Use these UML diagrams to code your classes; note: the # symbol means Protected access.


Canidae

#social : string  

#coatColor : string

#litterSize : int

+Canidae()

+Canidae(soc : string, color : string, litter : int)

<setters and getters can be omitted or coded; they are optional>

+printInfo() : void


Fox       

#continent : string

#habitat : string

+Fox()

+Fox(soc : string, color : string, litter : int, cont : string, hab : string)

+setContinent(cont : string) : void

+getContinent() : string

+setHabitat(hab : string) : void

+getHabitat() : string

+printInfo() : void  


Wolf

#packSize : int

#habitat : string

+Wolf()

+Wolf(soc : string, color : string, litter : int, pack : int, hab : string)

+setPack(pack : int) : void

+getPack() : int

+setHabitat(hab : string) : void

+getHabitat() : string

+printInfo() : void

RedFox

-avgWeight : double

-activity : string  


RedFox()

RedFox(soc : string, color : string, litter : int, cont : string, hab : string, weight : double, act : string)

+setWeight(wgt : double) : void

+getWeight() : double

+setActivity(activity : string) : void

+getActivity() : string

+printInfo() : void


GrayWolf

-packPosition : string

-gender : string  

+GrayWolf()

+Gray Wolf(soc : string, color : string, litter : int, pack : int, hab : string, pos : string, gen : string)

+setPosition(pos : string) : void

+getPosition() : string

+setGender(gen : string) : void

+getGender() : string

+printInfo() : void  


Code all five classes using header files and putting member function code into separate .cpp files. Be sure to indicate inheritance when you code the header files for Fox, Wolf, RedFox and GrayWolf. Be sure to include the proper header files where needed.


NOTES:

  • If you use the Add Class tool of Visual Studio, notice that after you enter the name for a class, there is another box titled "Base Class". For the child classes, you can put in the class name of the immediate Parent and then Visual Studio creates the inheritance code for you, that is, it will start the class as (example):

class Fox : public Canidae {

  • The constructors of your derived classes should include the parents' attributes (as shown in the UML) and the current class attributes. Use the parent's constructor for the parent's attributes as shown in the Exercise. Default constructors only need to initialize class attributes; Parent default constructors are automatically called.
  • Your printInfo() methods should call the parent's printInfo() and add any unique information. No redundant print statements allowed! Use inheritance.


In the main function:

Make a RedFox object with this data: In the family Canidae with a social structure of "pair/family", a coat color of "red" and a litter size of 6. As a fox, the continent would include "the northern hemisphere" and its common habitat is "diverse". Its average weight is 12 pounds and it is usually active at "dawn/dusk". Print all information.

Make GrayWolf object with this data: In the family Canidae with a social structure of "pack", a coat color of "white to black" and a litter size of 4. As a wolf, the pack size averages 6 and its usual habitat is "diverse". The gray wolf in question is an alpha male.

"


2.png

2.png

Recently Asked Questions

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question
Ask Expert Tutors You can ask You can ask ( soon) You can ask (will expire )
Answers in as fast as 15 minutes