예제 #1
0
파일: main.cpp 프로젝트: ameks94/PrataTasks
int main()
{
	using std::cin;
	using std::cout;
	using std::endl;

	Worker *element;

	QueueTP<Worker *> queue;
	for (int i = 0; i < SIZE; i++)
	{
		cout << i + 1 << "iteration" << endl;
		char k;
		do 
		{
			system("cls");
			cout << "Enter the employee category:\n"
				<< "w: waiter s: singer "
				<< "t: singing waiter q: quit\n";
			cin.get(k);
			cin.clear();
			cin.sync();
		}
		while(k != 'w' && k!= 's' && k != 't' && k != 'q');

		if (k == 'q')
			break;

		switch(k)
		{
		case 'w': element = new Waiter;
			break;
		case 's': element = new Singer;
			break;
		case 't': element = new SingingWaiter;
			break;
		}
		element->Set();
		queue.enqueue(element);
	}

	cout << "\nHere is your staff:\n";

	for (int i = 0; i < SIZE; i++)
	{
		cout << endl;
		queue.dequeue(element);
		element->Show();
		delete element;
	}

	cout << "Bye.\n";

	system("pause");
	return 0;
}
예제 #2
0
파일: workmiq.cpp 프로젝트: Silent77/prata6
int main()
{
   using std::cin;
   using std::cout;
   using std::endl;
   using std::strchr;

   QueueTP<Worker *> lolas(SIZE);
   

    int ct;
    Worker * pwk;
    for (ct = 0; ct < SIZE; ct++)
    {
        char choice;
        cout << "Enter the employee category:\n"
            << "w: waiter  s: singer  "
            << "t: singing waiter  q: quit\n";
        cin >> choice;
        while (strchr("wstq", choice) == NULL)
        {
            cout << "Please enter a w, s, t, or q: ";
            cin >> choice;
        }
        if (choice == 'q')
            break;
        switch(choice)
        {
            case 'w':   pwk = new Waiter;
                        break;
            case 's':   pwk = new Singer;
                        break;
            case 't':   pwk = new SingingWaiter;
                        break;
        }
        cin.get();
        pwk->Set();
        lolas.enqueue(*pwk);
        delete pwk;
    }

    cout << "\nHere is your staff:\n";
    while (!lolas.isempty())
    {
        cout << endl;
        lolas.dequeue(*pwk);
        pwk->Show();        
    }
    cout << "Total call of base constructor:" << Worker::num_of_constructors_ << endl;
    cout << "Bye.\n";
    return 0; 
}
예제 #3
0
int main() {
    Queue<Worker *> work_queue;
    int ct;
    for (ct = 0; ct < SIZE; ct++) {
        char choice;
        cout << "Enter the employee category:\n"
            << "w: waiter  s: singer  "
            << "t: singing waiter  q: quit\n";
        cin >> choice;
        while (strchr("wstq", choice) == NULL)
        {
            cout << "Please enter a w, s, t, or q: ";
            cin >> choice;
        }
        if (choice == 'q')
            break;
		Worker *w;
        switch(choice)
        {
            case 'w':   w = new Waiter;
						work_queue.enqueue(w);
                        break;
            case 's':   w = new Singer;
						work_queue.enqueue(w);
                        break;
            case 't':   w = new SingingWaiter;
						work_queue.enqueue(w);
                        break;
        }
        cin.get();
        w->Set();
    }

	cout << work_queue.queuecount() << endl;
	for ( int i =  work_queue.queuecount(); i > 0; i-- ) {
		Worker *tmp;
		work_queue.dequeue(tmp);
		tmp->Show();
		cout << endl;
		delete tmp;
	}

	system("Pause");
    return 0; 
}