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 Objects (Retired) Creating the MVP Comparing Characters

I have modeled an assistant for a tech conference. Since there are so many attendees, registration is broken up into two

How to do this challenge? I'm very lost!

ConferenceRegistrationAssistant.java
public class ConferenceRegistrationAssistant {

  public int getLineFor(String lastName) {
    /* If the last name is between A thru M send them to line 1
       Otherwise send them to line 2 */
    if('A' < 'M'){
    int line = 1;
    return line;
    } else {
      int line = 2;
      return line;
    }
  }
}

2 Answers

OK - you've got the right idea. You're setting a line variable and then returning it depending on a test. Your test isn't quite right because 'A' is always less than 'M'. You want to test the first line of the person's name (lastName that is passed into the function as a parameter) to see if it is less than (or equal to) 'M'. Using the charAt() method allows you to test the first letter of the string.

If it is less than (or equal to) then set line to 1, else it is 2 - return line.

Here's the test and queue division:

if(lastName.charAt(0) <= 'M') {
    line = 1;
} else {
    line = 2
}

You then add return line and that's it!

Steve.

Hi there,

Have a look at this post that goes through this task in some detail.

I'll add some more points in here more specific to your current solution.

Steve.