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

Lucas Santos
Lucas Santos
19,315 Points

Need help, really do not understand this question nor do I see how this resembles the video.

Ok so far this course is by far the most difficult and I have many question. re-watched the videos about 10 times and went over everything and still difficult to understand. Then after I understood a good part of the game.java and prompter.java I got this question and I have no clue what to do here or how this applies. I am really stuck on this, wish the question was more detailed because i'm clueless as to what to do here.

Question:

I have modeled an assistant for a tech conference. Since there are so many attendees, registration is broken up into two lines. Lines are determined by last name, and they will end up in line 1 or line 2. Please help me fix the getLineFor method.

NEW INFO: chars can be compared using the > and < symbols. For instance 'B' > 'A' and 'R' < 'Z'

What I came up with:

public class ConferenceRegistrationAssistant {

  private String line1;
  private String line2;

  public ConferenceRegistrationAssistant(){
    line1 = "";
    line2 = "";
  }

  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(lastName.charAt('A' < 'B')){
    line1 =+ lastName;
    }
    int line = 0;
    return line;
  }

}
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 */
    int line = 0;
    return line;
  }

}

By the way the part in the entire video that was the most confusing was when you past the object as a field in Prompter.java and constructed a game object and back in hangman.java you passed the game instance in the prompter argument. Wish he was more descriptive on what this is achieving and how the objects relate to one another.

1 Answer

Craig Dennis
STAFF
Craig Dennis
Treehouse Teacher

Hey Lucas,

In the second half of the course as you are using skills you learned in the first half, the videos do not directly relate to the previous video. They are all skills you learned.

For this challenge, your code should stay in the provided method (getLineFor) body, no need to go outside.

Here is your HINT: Using the first character of the last name passed into the method, you should return either 1 if the character is less than 'M' and 2 if it is greater.

Hope that helps!

Lucas Santos
Lucas Santos
19,315 Points

Thanks Craig, got it.