Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The class Chimney represents a smoke ventilation system. Consider the class diag

ID: 3668106 • Letter: T

Question

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)

Chimney( );
void open();
void close();
bool isOpen() const;
void setHeight( double height );
double getHeight() const;

bool isOpen;
double myHeight;


Based on the information shown here, a possible implementation (.cpp) for Chimney is shown below.

isOpen = false;
myHeight = 0;

isOpen = true;

isOpen = false;

return( isOpen );

myHeight = height;

return( myHeight );


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 Fireplace’s 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?

Class Diagram Class Definition (.h file) Chimney Chimney( );
void open();
void close();
bool isOpen() const;
void setHeight( double height );
double getHeight() const; bool isOpen;
double myHeight; // in feet class Chimney {
public:

Chimney( );
void open();
void close();
bool isOpen() const;
void setHeight( double height );
double getHeight() const;

private:

bool isOpen;
double myHeight;

};

Explanation / Answer

Fireplace.h:-

class Fireplace
{
private:
bool is_Lit;
Chimney my_Chimney;
public:
Fireplace();
Fireplace(double heigh, bool fire);
void light();
void extinguish();
};

Fireplace.cpp:-

Fireplace::Fireplace()
{
my_Chimney.open();
my_Chimney.setHeight(10);
is_Lit = true;
}
Fireplace::Fireplace(double height, bool fire)
{
is_Lit = fire;
if(fire)
{
my_Chimney.open();
}
else
{
my_Chimney.close();
}
my_Chimney.setHeight(height);
}
void Fireplace::light()
{
my_Chimney.open();
is_Lit = true;
}
void Fireplace::extinguish()
{
is_Lit=false;
my_Chimney.close();
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote