Step1 - Define two classes, Whole and part. Use a strong \"has a\" relationship with the...

90.2K

Verified Solution

Question

Programming

Step1 - Define two classes, Whole and part. Use a strong \"has a\"relationship with the two classes.

           Constructor Functions

           Define a default constructor for the Part class.

                       Default just prints out \"In default part constructor\"

           Define a default and a parm constructor for the Whole class.

                       In Whole Default constructor assigns wholeName = \"None\"; and printsout \"In whole default Constructor\"

                       In Whole Parm constructor - Passes in name to WholeName and

                       Then It prints out value of wholeName variable and \"In Whole parmconstructor\"

           Destructor Functions

           Define a destructor function for the part class.

           Define a string variable called wholeName in the whole class.

           Define a getName function for whole class.

Two test.

Step 2 - Declare a Whole W1, with default constructor

            Have the Wholeconstructor print \"called default constructor\", and contents ofwholeName variable

            Have the WholeDestructor print \"called destructor\", and contents of wholeNamevariable

           Declare a Whole W2, with a parm constructor - Have it pass in\"w2\"

            Have theWhole constructor print \"called parm constructor\", and contents ofwholeName variable.

            Have the WholeDestructor print \"called destructor\", and the contents of wholeNamevariable.

Step 3 - use the dot

           Use the dot notation to print out the contents of W1 wholeNamevariable

           Use the dot notation to print the contents of W2 wholeNamevariable

Answer & Explanation Solved by verified expert
4.4 Ratings (625 Votes)
HASARelationshipBasically the term Composition reffers to the HASA Relationshipie the use of instance    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students