Problem
Statement:
We
have the following part of class diagram showing aggregation
relationship:
You
are required to implement above class diagram (complete program) in
C++ with all data members, constructors, member functions and concept
(aggregation) given in the class diagram/table
Class Name |
Functions |
|
-Default
constructor
|
|
-Default constructor |
|
-Default
constructor
|
Dairy Store |
-Default
constructor
|
Apple |
-Default
constructor
|
Grapes |
-Default
constructor
|
Guava |
-Default
constructor
|
Tetra Milk |
-Default
constructor
|
Whitener |
-Default
constructor
|
Cream |
-Default
constructor
|
Cooking Oil |
-Default
constructor
|
Rice |
-Default
constructor
|
Flour |
-Default
constructor
|
Solution or Download.cpp
#include <iostream> using namespace std; class Apple{ public: Apple(){ cout<<"Apple Constructor called\n"; } }; class Grapes{ public: Grapes(){ cout<<"Grapes Constructor called\n"; } }; class Guava{ public: Guava(){ cout<<"Guava Constructor called\n"; } }; class FruitStore{ Apple a; Grapes g; Guava gv; public: FruitStore(){ cout<<"\nFruit Store Constructor called\n\n"; } }; class CookingOil{ public: CookingOil(){ cout<<"Cooking Oil Constructor called\n"; } }; class Rice{ public: Rice(){ cout<<"Rice Constructor called\n"; } }; class Flour{ public: Flour(){ cout<<"Flour Constructor called\n"; } }; class GroceryStore{ CookingOil c; Rice r; Flour f; public: GroceryStore(){ cout<<"\nGrocery Store Constructor called\n\n"; } }; class TetraMilk{ public: TetraMilk(){ cout<<"Tetra Milk Constructor called\n"; } }; class Whitener{ public: Whitener(){ cout<<"Whitener Constructor called\n"; } }; class Cream{ public: Cream(){ cout<<"Cream Constructor called\n"; } }; class DairyStore{ TetraMilk t; Whitener w; Cream c; public: DairyStore(){ cout<<"\nDairy Store Constructor called\n\n"; } }; class GroceryHome{ FruitStore f; GroceryStore g; DairyStore d; public: GroceryHome(){ cout<<"Grocery Home Constructor called\n\n"; } }; main(){ GroceryHome g; }