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 trialDavid Carlson
564 PointsCan't figure out the Challenge.
Can somebody explain what I'm supposed to do in the challenge??
Steve Hunter
57,712 PointsGabe,
You can click the 'View Challenge' button, top-right, to see the code challenge.
Steve.
2 Answers
Steve Hunter
57,712 PointsHi David,
For this, you need to use the lastName
parameter passed into the method, getLineNumberFor()
, and test its first character to see if it is within A & M or not. If the former, set lineNumber
to 1, else set it to 2.
I suggest investigating the charAt()
method for use on the lastName
string. That will give you the first character if you use it right. Then, you want an if/else conditional test should allow you to set the lineNumber
to either possible outcome. Then return that outcome.
Does that help?
Steve.
David Carlson
564 PointsIt clears up what I'm supposed to do, but what I don't understand is how to program it. If you could show me what to put and then explain what the code is doing that would solve my problems! Thanks so much!
David.
Steve Hunter
57,712 PointsI'm not going to stick a load of code here to solve the challenge but I am happy to look at your code and work through any issues. I'm sure you do know how to get through the code challenge so give it a go, post your code and I'll take you through any issues that throws up.
I've given you some pointers in the answer above, so have a play with those and keep hitting the Preview button to see if there's any errors. Do a bit of Googling to fix those errors and if you get nowhere, come back here with your code and I'll help in more detail.
It's 01:18 here now, so I'm off to sleep. Good luck; keep going; keep trying.
Let me know how you get on.
Steve.
David Carlson
564 PointsHi Steve, Quick question..... should I use the whole "scanner" deal he used in the video? Or just the char.At ()?
Steve Hunter
57,712 PointsHi David,
I don't think you need a Scanner
instance - we're not taking user input here. The method receives the lastName
as a parameter so where that came from isn't our concern here.
I'd take that parameter, get its first character with .charAt(0)
and test it for being less than 'N'
(or less than or equal to 'M'
) and set lineNumber
depending on the result of that test.
Make sense?
Steve.
David Carlson
564 PointsThanks so much!
Gabe Olesen
1,606 PointsGabe Olesen
1,606 PointsCan you post the code please?