Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java Java Data Structures - Retired Efficiency! Custom Serialization

Iván Martínez
Iván Martínez
11,278 Points

Help with "Did you remember to call the assist method on the CustomerSupportRep?" error.

The code challenge keeps asking if i did remember to call the assist method on CSR. What i'm doing wrong?

public void acceptCustomer(Customer customer) {
    CustomerSupportRep csr;

    csr = mSupportReps.poll();
    /********************************************
     * 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
     ********************************************
     */

    do {
      playHoldMusic();
    } while((csr = mSupportReps.poll()) == null);


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

    csr.assist(customer);

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

    mSupportReps.add(csr);

  }
Kareem Jeiroudi
Kareem Jeiroudi
14,984 Points

You solution works perfectly. The only thing you're missing is to keep checking for a new representative in the queue in the while loop, like this:

do {
playHoldMusic();
csr = mSupportReps.poll();
} while (csr == null);

3 Answers

Carlo Antonio Bilbao
Carlo Antonio Bilbao
24,113 Points

I used an if else statement instead. csr =mSupportReps.poll(); if (csr == null) { playHoldMusic(); } else { csr.assist(customer); mSupportRep.add(csr; }

Hope this helps

It helped me too. Thank you.

Kareem Jeiroudi
Kareem Jeiroudi
14,984 Points

Strange, although it says explicitly to use a while loop. I'm having the same problem as Iván Martínez.

Andrea Marloni
Andrea Marloni
8,436 Points

Or:

public void acceptCustomer(Customer customer) {
    CustomerSupportRep csr;
    csr = mSupportReps.poll();
    while (csr == null) {
      playHoldMusic();
      csr = mSupportReps.poll();
    }
    csr.assist(customer);
    mSupportReps.add(csr);
  }
George Georgiou
George Georgiou
5,287 Points

Consider using the .peek() method in the loop, before assigning any value to csr