What I have is pretty Basic, but the method for getting these enumerated datatypes is a protected method within a class. What I am trying to accomplish is to use a getter() to return some data of type "the enumerated type". This will then be called by assignment to a vairable that is used in a switch block of code. Here are the parts of my code that pertain to the enum, any help would be appreciated.
//Global Decleration, that shows friendly akas for media types
enum MC_MEDIA_TYPE{ AUDIO_CASSETTE = 1, AUDIO_CD, VIDEO_VHS, VIDEO_DVD };
//Function prototypes listed from the public: area of my class
public:
void AddMedia( );//user adds a media object to the collection
//Function prototypes listed from the protected: area of my class
protected:
//prints Media type Menu
void DisplayMediaTypeMenu( );
//gets a friendly name for the type of media selected
MC_MEDIA_TYPE GetMediaTypeSelection( );
//Implementation of the above prototypes
//user adds a media object to the collection
void MediaCollection::AddMedia( )
{
MC_MEDIA_TYPE Selection;
if( CurrentMCSize < MEDIA_COLLECTION_SIZE )
{
DisplayMediaTypeMenu( );
Selection = GetMediaTypeSelection();
switch( Selection )
{
case AUDIO_CASSETTE: //Collection[CurrentMCSize] = new AudioCassette;
cout << "creat a cassette" << endl;
break;
case AUDIO_CD: //Collection[CurrentMCSize] = new AudioCD;
cout << "create a cd" << endl;
break;
case VIDEO_DVD: //Collection[CurrentMCSize] = new VideoDVD;
cout << "creat a dvd" << endl;
break;
case VIDEO_VHS: //Collection[CurrentMCSize] = new VideoVHS;
cout << "create a vhs" << endl;
break;
default: cout << "\nInvalid selection\n\n";
}//end switch block
}
else cout << "Media collection is full - cannot add another media item at this time." << endl;
cout << "Please make room in your media storage by deleting something first." << endl;
}
//prints Media type Menu
void DisplayMediaTypeMenu( )
{
cout << "\n|===============| Media Types |===============:" << endl;
cout << "| 1) AUDIO_CASSETTE" << endl;
cout << "| 2) AUDIO_CD" << endl;
cout << "| 3) VIDEO_DVD" << endl;
cout << "| 4) VIDEO_VHS" << endl;
}
//gets a friendly name for the type of media selected (This is protected)
MC_MEDIA_TYPE GetMediaTypeSelection( )
{
MC_MEDIA_TYPE selection;
cout << "\nSelect one of the following choices: " << endl;
cin >> selection;
return selection;
}
So this boils down to the the menu being displayed, then selection will call the function for the user to input their type selection and assign that value to itself so it can be passed on to the switch statements. I am having trouble getting the GetMediaTypeSelection to return the values I need based upon user input.