Question
I need the answer in C++ and I need a Watertank.h file and Watertank.cpp file. Create a class called watertank. A watertank has two data
I need the answer in C++ and I need a Watertank.h file and Watertank.cpp file.
Create a class called watertank. A watertank has two data members: current volume and maximum capacity. Create appropriate constructors, mutators, and accessors to support the tanks function. Among these, create a fill() member function to allow water to be added to the simulated tank. Create a drain() member function to allow water to be removed from the tank. Create an isEmpty() member function to indicate true if the current volume is 0 and false otherwise.
Additionally, overload following operators:
- > allows two watertank objects to be compared and returns true if the first object has more current volume than the second.
- < allows two watertank objects to be compared and returns true if the first object has less current volume than the second.
- == allows two watertank objects to be compared and returns true if the first object has less current volume than the second.
Create at least two watertank objects in the main function. Assign a current volume and maximum capacity to each. Demonstrate the use of fill(), drain(), isEmpty() and compare the two objects using >, <, and ==.
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