Assume you are designing two classes as below:Base Class: GarmentThis class represents the general properties common to all clothing items.Private Members:string material (e.g., “Cotton”, “Polk”)string color (e.g., “Blue”, “Black”)int basePricePublic Members:Constructor: Initializes members.virtual Method: toString() – Prints the basic garment details.Virtual Method: calculatePrice() – Returns basePrice.Derived Class: OuterwearThis class adds properties specific to items worn over other clothing, and has a different price calculation.Private Members:bool isWaterproofstring liningType (e.g., “Fleece”, “Quilted”)Public Members:Constructor: Calls the base class constructor and initializes its own members.Overridden Method: calculatePrice() – Overrides the base class method. It could return basePrice * 1.5 if Waterproof is true, or just basePrice * 1.2 otherwise.Method: toString() – Prints its specific details.Go ahead write code for implementing the calculatePrice() function for both base and derived class.
Blog
Given code below:int total=0;int i; for(int i=5; i
Given code below:int total=0;int i; for(int i=5; i
Constructors should be declared in the private section.
Constructors should be declared in the private section.
Given the following section of code in C++:class AB:public B…
Given the following section of code in C++:class AB:public BC {…. … ….}; Which of the following statements is correct based on the given code above?
In which country does the government give money collected th…
In which country does the government give money collected through taxes to churches?
Which of the following is an example of “Distribution” in Pu…
Which of the following is an example of “Distribution” in Public Policies?
One of the features that Indian democracy shares with the Un…
One of the features that Indian democracy shares with the United States is that both
In which country is the President selected by an electoral c…
In which country is the President selected by an electoral college of legislators?
In which country is the head of state a figurehead with litt…
In which country is the head of state a figurehead with little real power
What is the lower chamber of the Russian legislature is call…
What is the lower chamber of the Russian legislature is called?