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 trialBrian Maimone
Courses Plus Student 1,644 PointsCall center challenge questions. I'm getting two errors but I think my logic is close. Would appreciate feedback. Thanks
The errors:
./CallCenter.java:33: error: cannot find symbol assist(customer); ^ symbol: method assist(Customer) location: class CallCenter ./CallCenter.java:41: error: cannot find symbol mSupportReps.add(CustomerSupportRep.name); ^ symbol: variable name location: class CustomerSupportRep
The code:
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 ********************************************/ while (mSupportReps.size() == 0) { playHoldMusic(); }
/********************************************
* TODO (2)
* After we have assigned the rep, call the
* assist method and pass in the customer
********************************************
*/
// CustomerSupportRep CSR = new CustomerSupportRep(); mSupportReps.poll(); assist(customer);
/********************************************
* TODO (3)
* Since the customer support rep is done with
* assisting, put them back into the queue.
********************************************
*/
mSupportReps.add(CustomerSupportRep.name);
}
public void playHoldMusic() { System.out.println("Smooooooth Operator....."); } }
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; }
}
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.....");
}
}
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 class Customer {
private String mName;
public Customer(String name) {
mName = name;
}
public String getName() {
return mName;
}
}
3 Answers
Brian Maimone
Courses Plus Student 1,644 PointsOk - fixed both errors. Now I get the "Bummer have you called the assist method" yet my output.html shows the text from executing the assist method: "Hello Bob, my name is Brian, how can I assist you. ... Is there anything else I can help you with?" Need more help thanks.
Current code:
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 = new CustomerSupportRep("Brian"); /******************************************** * 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 ********************************************/ while (mSupportReps.size() == 0) { playHoldMusic(); }
/********************************************
* TODO (2)
* After we have assigned the rep, call the
* assist method and pass in the customer
********************************************
*/
csr.assist(customer);
mSupportReps.poll();
/********************************************
* TODO (3)
* Since the customer support rep is done with
* assisting, put them back into the queue.
********************************************
*/
mSupportReps.add(csr);
}
public void playHoldMusic() { System.out.println("Smooooooth Operator....."); } }
Hayes McCardell II
643 PointsI can take care of your first error.
The problem is you're calling a constructor here:
CustomerSupportRep CSR = new CustomerSupportRep();
There is no default constructor for the CustomerSupportRep class, only one that takes a string.
So if you refactor as:
CustomerSupportRep CSR = new CustomerSupportRep("Bob");
It should work.
The base generated code already creates a csr for you.
I would think the rest would be csr.assist(customer) but that does not seem to be working.
Brian Maimone
Courses Plus Student 1,644 PointsThanks. Got rid of first error but still have second.