Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Need help creating the following code Bottle(double, const char *); // parameter constructor Bottle( ); // default constructor double fill(double); double fullness( ); void display(
Need help creating the following code
Bottle(double, const char *); // parameter constructor Bottle( ); // default constructor double fill(double); double fullness( ); void display( ); double operator++(int); // postfix version double operator--(int); // postfix version
SPECIFICATIONS: Create a C++ class called a "Bottle" that stores a double and a string no more that 30 characters long. The Bottle class MUST be prototyped exactly as listed below: class Bottle { private: // PRIVATE member data char units [31]; double capacity, amount; public: // PUBLIC member functions Bottle (double, const char *); // parameter constructor Bottle(); 11 default constructor double fill(double); double fullness(); void display(); double operator++(int); // postfix version double operator--(int); // postfix version Develop and code a class, named Bottle, with the following publicly accessible characteristics: PART 1 : Constructors When an instance of a Bottle is created, a double (indicating the capacity of the Bottle) and a constant character string (indicating the unit of capacity, max. 30 characters) may be supplied. NOTE: To indicate that a string is accepted as constant, the keyword: "const" is used. If no parameters are supplied when creating a Bottle, then the Bottle's capacity should be set to 8.00 and the units to "Litre". All new Bottle's start out empty. NOTE: 2 overloaded constructors MUST also be coded for this class (see below). PART 2: There is a member function: double fill(double) which is passed an amount to be poured into the bottle. This amount is added to the amount already in the Bottle, unless the total would exceed the capacity of the Bottle, in which case only enough to fill the Bottle is added. The amount left over, if any, is returned. PART 3: There is a member function: double fullness() which returns, as a percent, how full the Bottle is. PART 4: There is a member function: void display ( ) which displays the current state of the Bottle, in the following format: This 5.00 Litre bottle has 4.50 Litres in it. (where this particular Bottle has a capacity of 5.00, a unit of "Litre" and has had 4.5 poured into it). NOTE: All output MUST use the C++ method to display output (using cout #include
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started