Question: Hi tutor abstract class Define and implement a class named animal that has the following constructor and attributes: animal(string n, int v) ;// creates an
Hi tutor
abstract class
Define and implement a class namedanimalthat has the following constructor and attributes:
animal(string n, int v) ;// creates an animal with name n and body volume v.
// animals are allocated a unique ID on creation
string name ;// the animal's name
int animalID ;// the animal's unique ID
int volume ;// the volume of the animal's body
Following the principles of encapsulation and information hiding, set the proper access modifiers for the attributes and provide methods to access the object's data. You need tosetthenameandvolumeof an animal, as well asgetthe animal'sname,animalIDandvolume. There must not be asetfunction foranimalID.Thegetandsetfunction names should be the attribute name prefixed with "get_" or "set_" respectively. For example, thegetandsetmethods forvolumewould be namedget_volumeandset_volumerespectively.
Declare theget_namefunction aspure virtual. When selecting between the three types of access modifiers for each of the attributes, note that none of the attributes may be public but, in the further questions child classes of animal are to be implemented that will need to directly access the attributesnameandanimalID.
please provide some expamnication. thanks so much!
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
