本文整理汇总了C++中Console::delay方法的典型用法代码示例。如果您正苦于以下问题:C++ Console::delay方法的具体用法?C++ Console::delay怎么用?C++ Console::delay使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Console
的用法示例。
在下文中一共展示了Console::delay方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[])
{
int r = 0;
Console console;
std::string input;
bool userIsLoggedIn = false;
console.init();
while (1)
{
input = console.read();
std::transform(input.begin(), input.end(), input.begin(), ::toupper);
// split the string of input
std::stringstream strstream(input); // strstream is used for splitting
// the input
std::istream_iterator<std::string> start(strstream);
std::istream_iterator<std::string> end;
std::vector<std::string> input_split(start, end);
strstream.clear();
if (input_split.size() < 1)
break;
if (input_split[0] == "LOGON")
{
bool founduser = false, foundpass = false;
std::string username;
// user wants to log on
console.delay(750);
if (input_split.size() < 2)
{
console.write("\nENTER USERNAME NOW\n\n");
username = console.read();
console.delay(750);
}
else
username = input_split[1];
for (int i = 0; i<arraysize(usernames); i++)
{
if (username == usernames[i])
{
founduser = true;
console.write("\nENTER PASSWORD NOW\n\n");
std::string password = console.read();
if (password == userpasswords[i])
{
userIsLoggedIn = true;
foundpass = true;
console.write("\nWELCOME, ");
console.write(username);
console.write(".\n\n");
r = consoleSession(console, i);
}
else
console.write("\nERROR - INCORRECT PASSWORD\n\n");
}
}
if (!founduser)
console.write("\nERROR - USER DOES NOT EXIST\n\n");
else
{
if (userIsLoggedIn)
{
if (r == 0)
break;
else
userIsLoggedIn = false;
}
}
}
else if (input_split[0] == "EXIT")
break;
else
console.write("\nERROR - USER MUST BE LOGGED ON\n");
console.writeNoDelay("\n");
}
return 0;
}