Hi,
I got this coding working but i want to improve it.
I want to make sure that the frist word i read is a string without numbers.
Then i want to make sure the second / third word are int / floats...
I was thinking in using isalpha but i donīt know if is the best way.
And maybe change the code to switchs so i donīt have 20 (If elses)...
Code:
int main() {
//// The Map will be 60x60 (Example)
//Mundo myMundo(60);
//// going to focus the board on 15 / 15
//myMundo.drawTerrain(60, 60);
string command, parse;
istringstream is; // Going to get the input from the user. (String)
// While i got things to processsing i will do it one by one from the object not from the keyboard
do {
cout << "Command: ";
getline(cin, command); //Get the full string
// Need to convert the object before use it.
is.str(command);
// Going to transfer everything i receive in lowercase
transform(command.begin(), command.end(), command.begin(), tolower);
// If the string is diferent from "exit" i will go execute the commands of the strings.
if (command != "sair") {
while (is >> parse) {
if (command == "defmundo") {
cout << "defmundo" << endl;
defmundo(3);
}
else if (command == "defen")
{
cout << "defen" << endl;
}
else if (command == "defpc")
{
cout << "defpc" << endl;
}
else {
cout << "Command not valid" << endl;
}
}
// I just finished to use my string i need to clean it up to i can receive other clean one.
is.clear();
}
// ... Other 20 options....
} while (command != "sair");
cout << "exit of the cycle" << endl;
getchar();
return 0;
}