The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | May 2017 |
| Last Sign in: | 398 Weeks Ago, 2 Days Ago |
| Questions Answered: | 66690 |
| Tutorials Posted: | 66688 |
MCS,PHD
Argosy University/ Phoniex University/
Nov-2005 - Oct-2011
Professor
Phoniex University
Oct-2001 - Nov-2016
C++ programming problem
The class Chimney represents a smoke ventilation system. Consider the class diagram shown below.
Each instance of a Chimney has a height, a shape and can be either opened or closed. Here is the class definition (.h)
| Class Diagram | Class Definition (.h file) | |||
|
class Chimney { public: Chimney( ); bool isOpen; |
Based on the information shown here, a possible implementation (.cpp) for Chimney is shown below.
| Chimney::Chimney( ) {
isOpen = false; void Chimney::open() { isOpen = true; }void Chimney::close() { isOpen = false; }bool Chimney::isOpen() const { return( isOpen ); }void Chimney::setHeight( double height ){ myHeight = height; }double Chimney::getHeight() const { return( myHeight ); } |
Based on this implementation of Chimney, define and implement the class Fireplace (a .h file and a .cpp
file). A Fireplace can be lit or extinguished and always has a Chimney to ventilate the smoke away. The
relationship between Fireplace and Chimney is shown in the diagram below.
Make sure your definition of Fireplace supports the following kinds of constructors:
Fireplace warmFire; |
By default, a lighted fireplace with an open chimneystack that has a height 10 feet |
Fireplace noFire( 20, false ); |
An unlit fireplace with a closed chimneystack that has a height of 20 feet |
In addition, create these two operations on Fireplace :
(1)void Fireplace::light();
(2)void Fireplace::extinguish();
These operations should adjust the Fireplace by manipulating the Chimney, opening the chimneystack
before the FireplaceA????1s fire is lit and closing the chimneystack after the fire is extinguished.
As currently defined, can any of the member operations you defined on the class Fireplace be marked const?
Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n.P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll