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

Russell Brookman
Russell Brookman
3,118 Points

They want me to put people into line one and two. If you can help that would be awesome. If not, I totally understand.

// This is as far as I get. Please tell me all the things I am doing wrong.

public class ConferenceRegistrationAssistant { private char theLines;

public 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; int line = 1; public boolean goToLine(char firstLetterOfLastName) { boolean lineOne = theLines.charOf(firstLetterOfLastName) > 'M'; if (lineOne) { return line; } else { return lineTwo; } } }

ConferenceRegistrationAssistant.java
public class ConferenceRegistrationAssistant {
  private char theLines;

  public 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;
    int line = 1;
    public boolean goToLine(char firstLetterOfLastName) {
      boolean lineOne = theLines.charOf(firstLetterOfLastName) > 'M';
      if (lineOne) {
      return line;
      } else {
        return lineTwo; 
      }
    }
  }

2 Answers

Blake Larson
Blake Larson
13,014 Points

Thank you for that post. I was wondering if you could quickly explain why there is only 1 variable (line) when we are making to different lines.

Jennifer Nordell
seal-mask
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Blake Larson yes there are two different lines. But you can think of the "line" variable as holding the number of the line. Line can either be line number one or line number 2. But at the end of the day, it's still a line, right? It's only the number that changes. In fact, we could have 10 lines and still it would only be the number of the line that's changing. We're simply setting up the variable line to hold the number of the line being assigned. Hope that helps!

Blake Larson
Blake Larson
13,014 Points

Yeah it's starting to make sense now. Thank you.