#ifndef valid
#define valid
#include <string>
using std::string;
#include <limits>
using std::numeric_limits;
using std::streamsize;
#include <iostream>
using std::cin;
using std::cout;
int validi (string output)
{
int input;
while ((cout << output) && !(cin >> input))
{
system ("msg * This is not a valid input.");
system ("cls");
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), '\n');
}
return input;
}
int validi (string output, string warning)
{
int input;
while ((cout << output) && !(cin >> input))
{
cout << warning << '\n';
system ("pause");
system ("cls");
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), '\n');
}
return input;
}
double validd (string output)
{
double input;
while ((cout << output) && !(cin >> input))
{
system ("msg * This is not a valid input.");
system ("cls");
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), '\n');
}
return input;
}
double validd (string output, string warning)
{
double input;
while ((cout << output) && !(cin >> input))
{
cout << warning << '\n';
system ("pause");
system ("cls");
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), '\n');
}
return input;
}
string validc (string output)
{
string input = "aa";
while (input.length() != 1)
{
cout << output;
cin >> input;
if (input.length() == 1) return input;
else
{
system ("msg * This is not a valid input.");
system ("cls");
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), '\n');
}
}
}
string validc (string output, string warning)
{
string input = "aa";
while (input.length() != 1)
{
cout << output;
cin >> input;
if (input.length() == 1) return input;
else
{
cout << warning << '\n';
system ("pause");
system ("cls");
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), '\n');
}
}
}
string valids (string output)
{
string input;
while ((cout << output) && !(cin >> input))
{
system ("msg * This is not a valid input.");
system ("cls");
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), '\n');
}
return input;
}
int validil (string output, int less)
{
int input;
while ((cout << output) && !(cin >> input) || input>=less)
{
system ("msg * This is not a valid input.");
system ("cls");
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), '\n');
}
return input;
}
int validil (string output, string warning, int less)
{
int input;
while ((cout << output) && !(cin >> input) || input>=less)
{
cout << warning << '\n';
system ("pause");
system ("cls");
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), '\n');
}
return input;
}
int validig (string output, int greater)
{
int input;
while ((cout << output) && !(cin >> input) || input<=greater)
{
system ("msg * This is not a valid input.");
system ("cls");
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), '\n');
}
return input;
}
int validig (string output, string warning, int greater)
{
int input;
while ((cout << output) && !(cin >> input) || input<=greater)
{
cout << warning << '\n';
system ("pause");
system ("cls");
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), '\n');
}
return input;
}
int validib (string output, int less, int greater)
{
int input;
while ((cout << output) && !(cin >> input) || input<less || input>greater)
{
system ("msg * This is not a valid input.");
system ("cls");
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), '\n');
}
return input;
}
int validib (string output, string warning, int less, int greater)
{
int input;
while ((cout << output) && !(cin >> input) || input<less || input>greater)
{
cout << warning << '\n';
system ("pause");
system ("cls");
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), '\n');
}
return input;
}
double validdl (string output, double less)
{
double input;
while ((cout << output) && !(cin >> input) || input>=less)
{
system ("msg * This is not a valid input.");
system ("cls");
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), '\n');
}
return input;
}
double validdl (string output, string warning, double less)
{
double input;
while ((cout << output) && !(cin >> input) || input>=less)
{
cout << warning << '\n';
system ("pause");
system ("cls");
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), '\n');
}
return input;
}
double validdg (string output, double greater)
{
double input;
while ((cout << output) && !(cin >> input) || input<=greater)
{
system ("msg * This is not a valid input.");
system ("cls");
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), '\n');
}
return input;
}
double validdg (string output, string warning, double greater)
{
double input;
while ((cout << output) && !(cin >> input) || input<=greater)
{
cout << warning << '\n';
system ("pause");
system ("cls");
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), '\n');
}
return input;
}
double validdb (string output, double less, double greater)
{
double input;
while ((cout << output) && !(cin >> input) || input<less || input>greater)
{
system ("msg * This is not a valid input.");
system ("cls");
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), '\n');
}
return input;
}
double validdb (string output, string warning, double less, double greater)
{
double input;
while ((cout << output) && !(cin >> input) || input<less || input>greater)
{
cout << warning << '\n';
system ("pause");
system ("cls");
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), '\n');
}
return input;
}
string validg (string output)
{
string input;
while ((cout << output) && !(getline(cin,input)))
{
system ("msg * This is not a valid input.");
system ("cls");
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), '\n');
}
return input;
}
#endif
|