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 trialIván Martínez
11,278 PointsHelp 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);
}
3 Answers
Carlo Antonio Bilbao
24,113 PointsI used an if else statement instead. csr =mSupportReps.poll(); if (csr == null) { playHoldMusic(); } else { csr.assist(customer); mSupportRep.add(csr; }
Hope this helps
Akhila Mobin
4,492 PointsIt helped me too. Thank you.
Kareem Jeiroudi
14,984 PointsStrange, although it says explicitly to use a while loop. I'm having the same problem as Iván Martínez.
Andrea Marloni
8,436 PointsOr:
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
5,287 PointsConsider using the .peek() method in the loop, before assigning any value to csr
Kareem Jeiroudi
14,984 PointsKareem Jeiroudi
14,984 PointsYou 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: