Exemplo n.º 1
0
void menuoptions(char decider, hashTable & table)
{
    data aData;
    char key[100];
    switch (decider)
    {
        case 'd':
            table.display();
            break;
        case 'a':
            makeData(table);
            break;
        case 'm':
            table.monitor();
            break;
        case 'e':
            cout << "Enter the stock ticker you'd like to edit: ";
            cin.ignore(100, '\n');
            cin.get(key, 100, '\n');
            table.modify(key);
            break;
            
        case 'r':
            cout << "Enter the stock ticker you'd like to remove: ";
            cin.ignore(100, '\n');
            cin.get(key, 100, '\n');
            table.remove(key);
            break;
            
        case 'f':
            cout << "Enter the stock ticker you'd like to find: ";
            cin.ignore(100, '\n');
            cin.get(key, 100, '\n');
            table.retrieve(key, aData);
            aData.print();
            break;
            
        case 'q':
            cout << "------Program Terminated------";
            break;
            
    }
}
Exemplo n.º 2
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;
	}
}