{I am a newbie to this forum and programing.
I am trying to write a program that takes a lists of technical support engineers and move them from the top of the list to the bottom when they get a support call assisted to them. "round robin"

A little background on this. I am not a student trying to get my homework done for me. I am one of the TSE's mentioned above. I've been told by various members in my organization that this would be difficult to do. I disagree and think that a C++ programmer could write this quite easily. I've got a C++ for dummy's book here and will try to learn this because I find it fascinating.

Anyway could someone give me an example of how this program} would look. I don't need it to compile or anything like that just looking for a place to start.

TIA

Recommended Answers

All 4 Replies

takes a lists of technical support engineers

From where? A file, a database?

when they get a support call assisted to them

How do we know when this happen?

More information is needed before I could possibly help.

It would be from an database Oracle I think. But what I am looking for is a basic example of a table or list of engineers that when they get a call assigned to them they go to the bottom of the table or list.
I fat fingered the word assisted, what I meant to say was assigned.
The way it is working now they use what they refer to as a wieghted average and the same engineers might stay at the top of the list when a call is assigned to them. I want to show that a "round robin" dropping the person who takes the call to the bottom of the list so the next engineer would be fist in line for the next call.

I sure it obvious I wont be doing the actual changing of any code. I am just looking for an example of what a program would look like that did this.
example:
3 engineers in a list or table or file (I'm really not sure) engineer 1 get a call or a case assignment he drops to the bottom of the list and engineer2 is now queued to take the next call. engineer2 takes a call then he goes to the bottom of the list and engineer3 is on top of the list etc.

I really appreciate your reply. I'm sure most people have a much grater understanding of this than I do.

I quickly wrote this up and forgot to post it. It could be written much better and could use many improvements but I think it handles the basic simulation you were asking for.

#include <iostream>
#include <string>
#include <vector>
#include <deque>

using namespace std;


struct Task;

class Engineer
{
    string m_name;
    vector<Task> m_tasks;
public:
    Engineer();
    Engineer(string name);
    string getName() const;
    void assignTask(Task task);
    vector<Task> getTasks() const;
};

struct Task
{
    Engineer assignee;
    string task;
};

Engineer::Engineer(): m_name("NO NAME") { }

Engineer::Engineer(string name): m_name(name) { }

string Engineer::getName() const
{
    return m_name;
}

void Engineer::assignTask(Task task)
{
    m_tasks.push_back(task);
}

vector<Task> Engineer::getTasks() const
{
    return m_tasks;
}

class Work
{
    deque<Engineer> m_workerQueue;
public:
    Work();
    Work(deque<Engineer> workers);
    bool newTask(Task& task);
    void addWorker(Engineer worker);
};

Work::Work() { }

Work::Work(deque<Engineer> workers): m_workerQueue(workers) { }

bool Work::newTask(Task& task)
{
    if (m_workerQueue.size() == 0)
        return false;

    Engineer nextEngineer = m_workerQueue.front();
    m_workerQueue.pop_front();

    nextEngineer.assignTask(task);
    task.assignee = nextEngineer;
    m_workerQueue.push_back(nextEngineer);

    return true;
}

void Work::addWorker(Engineer worker)
{
    m_workerQueue.push_front(worker);
}


int main(int argc, char *argv[])
{
    deque<Engineer> workers;
    workers.push_back(Engineer("Bob"));
    workers.push_back(Engineer("Tom"));
    workers.push_back(Engineer("Steve"));

    Work work(workers);

    for (int x = 0; x < 11; x++)
    {
        Task task;
        task.task = string(1, (char)(x+65));

        if (work.newTask(task))
        {
            cout << "Task: " << task.task << " assigned to: " << task.assignee.getName() << endl;
        }
    }

    Engineer newWorker("Harry");
    work.addWorker(newWorker);
    cout << newWorker.getName() << " is ready for work." << endl;

    for (int x = 11; x < 20; x++)
    {
        Task task;
        task.task = string(1, (char)(x+65));

        if (work.newTask(task))
        {
            cout << "Task: " << task.task << " assigned to: " << task.assignee.getName() << endl;
        }
    }

    return EXIT_SUCCESS;
}

How will you read from oracle database ? have you got C++ library for that ?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.