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

Richard Ziegler
Richard Ziegler
1,952 Points

Chars, charAt, lines, last names.. I have no idea where to go after this.

Hey everyone. I'm pulling my hair out with this one. I have absolutely no clue where to take my code at this point. I know I am missing something here but I have no idea how to make it work.

I don't know why the example code is setting the int line to 0, and returning it. Maybe that is where I am going wrong but it seems to be useless to me.

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;
  }

    public boolean firtLetterLastName (char letter) {
      boolean firstLetterLastName = letter.charAt(0) <= 'M';
      if (firstLetterLastName) {
      System.out.println("You belong in line 1.");
      } else {
      System.out.println("You belong in line 2.");
    }
    }
  }

3 Answers

Christopher Augg
Christopher Augg
21,223 Points

Hello Richard,

The instructions say that you are only supposed to fix the getlineFor method. Therefore, you do not want to create another method as you have done. You already have a good understanding of how to compare characters. You just need to do that step by step in the provided code. Here is a commented mix of the given method code and pseudo-code to get you on track:

       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;
           // need an if statement that compares lastName.charAt(0) <= 'M'
           // if true - line = 1;
           // else - line = 2;
           return line;
       }

Hope this helps.

Regards,

Chris

Richard Ziegler
Richard Ziegler
1,952 Points

Thank you so much Chris. I appreciate the help in this. It was becoming very frustrating, and while I felt like making a new method probably wasn't right... I wasn't sure how else to go about making the code work.

Thank you again.

Hi Richard,

Christopher covered this off nicely already but since you asked for my input, I'll point you in the direction of a previous post on this challenge. :-)

Steve.

Richard Ziegler
Richard Ziegler
1,952 Points

Thank you Steve! I'm still new to Treehouse and I'm not completely sure how to search properly for other people with the same questions. I appreciate the reply. :)

It isn't easy, no - I just remember when I've written an answer and point others to that post rather than typing it again!

There is some search functionality based on the subject of your initial suggested post but I think you did the right thing - just ask your question!!

Steve.

I think your problem its in Comparation that your using , try to use "=="

boolean firstLetterLastName = letter.charAt(0) <= 'M';