Open charlesamacon opened 4 years ago
I'm still trying to implement the switch statement but ran into a snag when I found it doesnt support strings, just int and char. I have seen the Allman style in other references but didnt know it had a name so I'll practice it and convert this code
I would recommend setting up an enum of your returnable strings and doing something like:
enum inputs
{
exit,
info,
n,
help,
[etc......]
};
inputs compareString (std::string const& inputString)
{
if (inputString == "exit") return exit;
else if (inputString == "info") return info;
....
else [return whatever you want for a default]
}
void yourFunction()
{
switch (compareString(inputString))
{
case exit:
.....
case info:
.......
}
}
Very cool, I didnt know about that. I will give that a try.
Code is a bit hard to read with current bracket style. This comes down to personal preference, but I recommend the Allman Style
Current Code:
Optional Allman Bracket Styling
Keeps it legible. Also, I would break out your
forceLower(uIn) == whatever
statements into a switch statement, if possible.