Java Java Data Structures Efficiency! Call Center Queue

Jack Cummins
Jack Cummins
17,403 Points

Anyone, please help! I really want to finish this Java Course, but can't without completing this assignment.@stevehunter

The asessment is: This is a Call Center application. There is a group of Customer Support Representatives that assist Customers. When representatives become available they enter the queue. The acceptCustomer method gets called when a new customer phones in. I've left 3 things for you todo in the comments below.

Thank You So much for helping! Jack

CallCenter.java
import java.util.ArrayDeque;
import java.util.Queue;

public class CallCenter {
  Queue<CustomerSupportRep> mSupportReps;

  public CallCenter(Queue<CustomerSupportRep> queue) {
    mSupportReps = queue;
  }

  public void acceptCustomer(Customer customer) {
    CustomerSupportRep csr;
    /********************************************
     * TODO (1) 
     * Wait until there is an available rep in the queue.
     * While there is not one available, playHoldMusic
     * HINT: That while assignmentcheck loop syntax we used to 
      *      read files seems pretty similar
     ********************************************
     */

    /********************************************
     * TODO (2) 
     * After we have assigned the rep, call the 
     * assist method and pass in the customer
     ********************************************
     */

    /********************************************
     * TODO (3) 
     * Since the customer support rep is done with
     * assisting, put them back into the queue.
     ********************************************
     */

  }

  public void playHoldMusic() {
    System.out.println("Smooooooth Operator.....");
  }

}
CustomerSupportRep.java
import java.util.List;
import java.util.ArrayList;

public class CustomerSupportRep {
  private String mName;
  private List<Customer> mAssistedCustomers;

  public CustomerSupportRep(String name) {
    mName = name;
    mAssistedCustomers = new ArrayList<Customer>();
  }

  public void assist(Customer customer) {
    System.out.printf("Hello %s, my name is %s, how can I assist you.%n",
                      customer.getName(),
                      mName);
    System.out.println("...");
    System.out.println("Is there anything else I can help you with?");
    mAssistedCustomers.add(customer);
  }

  public List<Customer> getAssistedCustomers() {
    return mAssistedCustomers;
  }

  public void acceptCustomer(Customer customer) {
    CustomerSupportRep csr;
  try  (CustomerSupportReps crs = new CustomerSupportReps(customer);
    CustomerQueue queue = new CustomerQueue (new CustomerSupportReps(crs));
       ) {
    Customer line;
    while(( line = queue.readLine()) =null) {
    }
  }  catch(IOException ioe) {
    System.out.printf("playHoldMusic %s", customer);

}
Customer.java
public class Customer {
  private String mName;

  public Customer(String name) {
    mName = name;
  }

  public String getName() {
    return mName;
  }

}

1 Answer

Yanuar Prakoso
Yanuar Prakoso
14,815 Points

Hi Jack

This question is similar with yours. Please read it first and please read it until finish. Basically all you have to do is following the TODOs. If you still have any question after reading that link I just gave you feel free to comment or add question in this same page. I will following this discussion.

I hope this can help a little.