Ejemplo n.º 1
0
int main()
{
	Counter obj;
	int n_min = 0;
	int n_max = 0;
	do{
		cout << "Input min ";
		cin >> n_min;
		cout << "Input max ";
		cin >> n_max;
		if ((n_max < n_min) || (n_min == n_max)){
			cout << "The maximum value should not be less than or equal to the minimum.";
		}
	} while ((n_max < n_min) || (n_min == n_max));
	obj.InputMin(n_min);
	obj.InputMax(n_max);
	system("pause");
	system("cls");
	int key = 0;
	do{
		cout << "Select an action:\n"
			"0. Exit.\n"
			"1. An increase of 1.\n"
			"2. Show the current value.\n";
		cin >> key;
		switch (key)
		{
		case 0:
			break;
		case 1:
			obj.Count();
			system("cls");
			break;
		case 2:
			obj.Show();
			system("pause");
			system("cls");
			break;
		default:
			cout << "Invalid input!";
			system("pause");
			system("cls");
			break;
		}
	} while (key != 0);
}
Ejemplo n.º 2
0
void checkString(ofstream &out_stream, string fileString, char fileChar, int &locCount, Counter &loc, Counter &parenthesis)
{
	bool found = false;
	
	// if string is empty
	if(fileString == "")
		return;
    
	// check against RESERVED array
	for(int i = 0; i < 25; i++)
	{
		if(RESERVED[i] == fileString)
		{
			out_stream << "RESERVED" << "          " << fileString << endl;
			found = true;
			locCounter(fileString, fileChar, locCount, loc);
		}
	}
    
	// check against PREDEFINED array
	for(int i = 0; i < 6; i++)
	{
		if(PREDEFINED[i] == fileString)
		{
			out_stream << "PREDEFINED" << "        " << fileString << endl;
			found = true;
		}
	}
    
	// defaults to IDENTIFIER
	if(!found)
	{
		out_stream << "IDENTIFIER" << "        " << fileString << endl;
		if(parenthesis.Count() == 1)
			parenthesis.SetFlag(1);
	}
}