#include <iostream>
using namespace std;
class enumTEST{
enum EMenu {NewGame, PlayAgain, RestartGame, Instructions} emenu;
public:
enumTEST(); // constructor
void testing1(); // test1 member function
void testing2(int a); // test2 member function
void testing3(int a); // test2 member function
};
enumTEST::enumTEST(){}; // Nothing to construct?! enum breaks OOP design.
//Shouldn't the deceleration of enum be hidden
//and then constructed like other variables in classes?
void enumTEST::testing1(){
//Test Enums, they print fine!
cout<<"Testing 1:\n";
cout<<"NewGame = "<<NewGame<<endl;
cout<<"PlayAgain = "<<PlayAgain<<endl;
cout<<"RestartGame = "<<RestartGame<<endl;
cout<<"Instructions = "<<Instructions<<endl;
}
void enumTEST::testing2(int choice){
cout<<"\n\nTesting 2:\n";
//Test sending of enum!
switch (choice){
case NewGame:
cout<<"Switch NewGame = "<<NewGame<<endl;
break;
case PlayAgain:
cout<<"Switch PlayAgain = "<<PlayAgain<<endl;
break;
case RestartGame:
cout<<"Switch RestartGame = "<<RestartGame<<endl;
break;
case Instructions:
cout<<"Switch Instructions = "<<Instructions<<endl;
break;
default:
cout<<"Switch default = DEFAULT"<<endl;
break;
};
}
void enumTEST::testing3(int choice){
cout<<"\n\nTesting 3:\n";
//Test sending of enum!
switch (choice){
case NewGame:
cout<<"Switch NewGame = "<<NewGame<<endl;
break;
case PlayAgain:
cout<<"Switch PlayAgain = "<<PlayAgain<<endl;
break;
case RestartGame:
cout<<"Switch RestartGame = "<<RestartGame<<endl;
break;
case Instructions:
cout<<"Switch Instructions = "<<Instructions<<endl;
break;
default:
cout<<"Switch default = DEFAULT"<<endl;
break;
};
}
int main(){
enumTEST TESTIT;
TESTIT.testing1(); // This works!
TESTIT.testing2(3); // This works!
enum EMenu {NGtest, PAtest, RGtest, Itest} emenu;
TESTIT.testing3(Itest);
// What I want is to use something like this!
TESTIT.testing2(Instructions); // dosn't work!!
// Wait until the user presses 'enter' key
cout <<"\n(Main) Press enter to exit...\n";
cin.ignore(10000, '\n');
return EXIT_SUCCESS;
}