asked 135k views
5 votes
In this programming assignment, you will create a hierarchy of classes (see below) that inherit from the beverage class. The base class (Beverage) and each derived class should have the appropriate attributes, parameterized constructor, destructor, setter/getter methods, and a toString() method that clearly defines the beverage. Write a program that creates several beverages (at least one of each from list below) using a parameterized constructor and displays the set of beverages you created.

1 Answer

3 votes

Answer:

public class GetInfo{

Beverage[] beverages=new Beverage[100];

int i=0;

GetInfo(Beverage b){

beverages[i]=b;

i++;

}

public void Display(){

for(int i=0;i<beverages.length;i++)

cout<<beverage[i].tostring();

}

Step-by-step explanation:

we are taking Beverages array to store all values and in constructor we are adding that to the list and Display() function prints the vale

answered
User UGuntupalli
by
8.2k points

No related questions found