Exemple #1
0
void executeCmd(char command, hashTable& table)
{
	stock stock;
	char key[MAX_LEN];

	switch(command)
	{
	case 'a': getStock(stock);
			  table.add(stock);
			  cout << endl << "the stock has been saved in the database. " << endl;
		break;

	case 'r': getString("\nPlease enter the ticker symbol of the stock you want to remove: ", key);
		      table.remove(key);
			  cout << endl << key << " has been removed from the database. " << endl;
		break;

	case 'm': getString("\nPlease enter the ticker symbole of the stock you want to modify: ", key);
				modify(key, table);
				cout << endl << key << " has been modified. " << endl;
		break;

	case 's': getString("\nPlease enter the name of the stock you want to search: ", key);
			  table.retrieve (key, stock);
			  cout << endl << "Information about " << key << ": " << endl << '\t' << stock << endl;
		break;

	case 'l': display(table);
		break;

	case 'c': table.monitor();
		break;

	default: cout << "illegal command!" << endl;
		break;
	}
}