Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

example _ main.cpp . #include #include Juice.hpp #include Tea.hpp #include Coffee.hpp using namespace std; int main ( ) { / / Default

example_main.cpp. #include
#include "Juice.hpp"
#include "Tea.hpp"
#include "Coffee.hpp"
using namespace std;
int main(){
// Default beverages
Juice default_juice;
Tea default_tea;
Coffee default_coffee;
cout default_juice.info() endl;
cout default_tea.info() endl;
cout default_coffee.info() endl;
// Test drink
cout "Drank 2 servings of OJ:" j1.drink(2) "calories" endl;
return 0;
}
1. Base class Beverage
This class should be implemented in files Beverage.hpp and Beverage.cpp (the starter code already provides declarations in Beverage.hpp). The class should include the following:
a. Protected data members:
i. name (string)
ii. calories_per_serving (integer)
b. Public methods:
i. Constructor that initializes both data members Beverage(string name, int calories_per_serving);
ii. Copy Constructor that initializes both data members using a reference to another Beverage object
Beverage(const Beverage& beverage);
iii. Default Constructor that takes no arguments and initializes name=default_beverage and
calories_per_serving=0.
Beverage();
iv. drink that returns an integer and takes one integer parameter servings. The return value is the
product of calories_per_serving and servings.
int drink(int servings);
v. info that returns a string and takes no parameters. The return value is a string in the following
format: name,calories_per_serving For example: water,0
string info();
2. Derived class Juice
This class should be implemented in files Juice.hpp and Juice.cpp. Class Juice should be a public child of class Beverage. The class should include the following:
a. Private data members: i. fruit (string)
b. Public methods:
i. Constructor that initializes data member and parent class
Juice(string name, int calories_per_serving, string fruit);
ii. Copy Constructor that initializes data members and parent class using a reference to another
Juice object
Juice(const Juice& juice);
iii. Default Constructor that takes no arguments and initializes fruit=unknown Juice();
iv. info that returns a string and takes no parameters. The return value is a string in the following format: name,fruit,calories_per_serving
For example: tropicana,orange,100 string info();
3. Derived class CaffeinatedBeverage
This class should be implemented in files CaffeinatedBeverage.hpp and CaffeinatedBeverage.cpp. Class CaffeinatedBeverage should be a public child of class Beverage. The class should include the following:
c. Protected data members:
i. caffeine_level (integer)
d. Public methods:
i. Constructor that initializes data member and parent class
CaffeinatedBeverage(string name, int calories_per_serving, int caffeine_level);
ii. Copy Constructor that initializes data members and parent class using a reference to another
CaffeinatedBeverage object
CaffeinatedBeverage(const CaffeinatedBeverage& caffeinated_beverage);
iii. Default Constructor that takes no arguments and initializes caffeine_level=0 CaffeinatedBeverage();
iv. info that returns a string and takes no parameters. The return value is a string in the following format: name,caffeine_level,calories_per_serving
For example: red_bull,10,100 string info();
4. Derived class Coffee
This class should be implemented in files Coffee.hpp and Coffee.cpp. Class Coffee should be a public child of class CaffeinatedBeverage. The class should include the following:
e. Private data members:
i. bean_type (string)
f. Public methods:
i. Constructor that initializes data member and parent class
Coffee(string name, int calories_per_serving, int caffeine_level,
string bean_type);
ii. Copy Constructor that initializes data members and parent class using a reference to another Coffee object
Coffee(const Coffee& coffee);
iii. Default Constructor that takes no arguments and initializes bean_type=default_bean
Coffee();
iv. info that returns a string and takes no parameters. The return value is a string in the following format: name,bean_type,caffeine_level,calories_per_serving
For example: starbucks,arabica,4,5 string info();
5. Derived class Tea
This class should be implemented in files Tea.hpp and Tea.cpp. Class Tea should be a public child of class CaffeinatedBeverage. The class should include the following:
g. Private data members: i. tea_type (string)
h. Public methods:
i. Constructor that initializes data member and parent class
Tea(string name, int calories_per_serving, int caffeine_level,
string tea_type);
ii. Copy Constructor that initializes data members and parent class using a reference to another Tea object
Tea(const Tea& tea);
iii. Default Constructor that takes no arguments and initializes tea_type=default_tea
Tea();
iv. info that returns a string and takes no parameters. The return value is a string in the following format: name,tea_type,caffeine_level,calories_per_serving
For example: lipton,black,2,10 string info();
Testing
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing Fundamentals Design And Implementation

Authors: David M. Kroenke

5th Edition

B000CSIH5A, 978-0023668814

More Books

Students also viewed these Databases questions