Trying to find out how to take an input and check if it is valid, If valid the answer get converted to int in main then passed into my switches. but, I keep getting an error. how can I do this right or is this just dead on arrival. Also is there a much shorter way to get the same result? I am new to programming any help will be appreciated. This is the body of classes.
#include "stdafx.h"
#include "Switchs.h"
Switchs::Switchs()
{
}
Switchs::~Switchs()
{
}
std::string Switchs::GetCase_Choice() // for retrieving the valid result
{
return Right_Choice;
}
//is equal to one override Right_Choice with result. if false pass to next case
std::string Switchs::Case_1(std::string Answer)
{
if (Answer = 1)
{
Right_Choice =Answer;
}
else
{
Case_2 (Answer);
}
return 0;
}
std::string Switchs::Case_2 (std::string Answer)
{
if (Answer = 2)
{
Right_Choice = Answer;
}
else
{
Case_3 (Answer);
}
return Answer;
}
std::string Switchs::Case_3 ( std::string Answer)
{
if (Answer = 3)
{
Right_Choice = Answer;
}
else
{
Case_Error (Answer);
}
return 0;
}
//if answer is not equal to above cases prompt them to reenter an answer then //enter code here pass that answer into Case_1
std::string Switchs::Case_Error (std::string Answer)
{
if (false)
{
std::string Choice_Num;
std::cout << "Please enter a number.";
std::cin >> Choice_Num;
Case_1(Choice_Num);
}
return 0;
}