C I have provided you with a sample class named TrashCan whi
C++
I have provided you with a sample class named TrashCan which has been diagrammed below and described in the online course content. You can acquire the source to the TrashCan class by by the codes below:
TrashCan.h
#ifndef TRASHCAN_H
#define TRASHCAN_H
#include
using namespace std;
class TrashCan {
public:TrashCan( );
TrashCan( int size );
TrashCan( int size, int contents );
void setSize( int size );
int getSize( );
int getContents( );
void addItem( );
void empty( );
void cover( );
void uncover( );
void printCan( );
private:
bool myIsCovered;
int my_Size;
int my_Contents;
};
#endif
TrashCan.cpp
#include \"TrashCan.h\"
TrashCan::TrashCan( ) {
myIsCovered = false;
my_Size = 0;
my_Contents = 0;
}
TrashCan::TrashCan( int size ) {
myIsCovered = false;
my_Size = size;
my_Contents = 0;
}
TrashCan::TrashCan( int size, int contents ) {
myIsCovered = false;
my_Size = size;
my_Contents = contents;
}
void TrashCan::setSize( int size ) {
my_Size = size;
}
int TrashCan::getSize( ) {
return( my_Size );
}
int TrashCan::getContents( ) {
return( my_Contents );
}
void TrashCan::addItem( ) {
my_Contents = my_Contents + 1;
}
void TrashCan::empty( ) {
my_Contents = 0;
}
void TrashCan::cover( ) {
myIsCovered = true;
}
void TrashCan::uncover( ) {
myIsCovered = false;
}
void TrashCan::printCan( ) {
cout
if (my_Contents != 1) {
cout
}
cout
}
For this unit, I\'d like you to identify additional member variables (data) that would be appropriate for the class TrashCan. I would also like you to identify additional methods (functions) that would be appropriate for the class TrashCan. Update and resubmit the .h file for TrashCan with the new possible methods and members you have identified commented and explained. YOU ARE NOT REQUIRED TO CODE UP ANYTHING MORE THAN THE .H FILE.
Solution
Here is the modified TrashCan.h file for you:
#ifndef TRASHCAN_H
#define TRASHCAN_H
#include
using namespace std;
class TrashCan {
public:TrashCan( );
TrashCan( int size );
TrashCan( int size, int contents );
void setSize( int size );
int getSize( );
int getContents( );
void addItem( );
void empty( );
void cover( );
void uncover( );
void printCan( );
bool isEmpty( ); //Checks whether the trashcan is empty or not.
bool isFull( ); //Checks if the trash can is full or not.
bool isCovered( ); //Checks if the trash can is covered.
private:
bool myIsCovered;
int my_Size;
int my_Contents;
};
#endif


