Call Center

For this question, you need to design a program for a call center. You must design the system in a way that is easily expandable.

This question will come in parts, and you need to answer the previous part before moving on. You are advised to copy the code from the previous section to be used as a starting point for the next.

Part One

The call center consists of many employees, who are able to handle incoming calls. An employee can be represented by their name (one word, no space).

Your system must support the following commands:

  • hire [employee]: Hire a new employee, adding them to the system. Input guarantees that the employee with the same name is not already in the database.
  • end [phone]: End the current conversation with the phone number phone, if phone is in a conversation. Print "Call between and ended". If phone is currently in the queue, or if it is not calling, do nothing.
  • dispatch [phone]: If phone is not already in a call and not already queued, assign the phone call to the first available employee (in the order they are inserted into the database). If all employees are unavailable, queue the call until an employee becomes available (in which case assign this phone call to the first available employee). When the call is connected, print "Connecting <phone> to <employee>".

Input

  • instructions: A list of instructions.

Output

The list of strings as outputs.

Examples

Example 1

Input:

1instructions = [
2  ["hire", "James"],
3  ["hire", "Angie"],
4  ["dispatch", "303-1142"],
5  ["dispatch", "583-9045"],
6  ["dispatch", "711-4375"],
7  ["end", "583-9045"],
8  ["end", "303-1142"],
9  ["end", "711-4375"]
10]

Output:

1[
2  "Connecting 303-1142 to James",
3  "Connecting 583-9045 to Angie",
4  "Call between 583-9045 and Angie ended",
5  "Connecting 711-4375 to Angie",
6  "Call between 303-1142 and James ended",
7  "Call between 711-4375 and Angie ended",
8]

Try it yourself

Solution

โ†
โ†‘TA ๐Ÿ‘จโ€๐Ÿซ