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 trialManuel Klettke
25,324 PointsBug when building from Germany (probably other countries as well)
When debugging, I noticed that I had no output besides the hard coded "System.out.print" lines. Going through the documentation, I found out that the method getInstance() in Score.getAmount uses the current default FORMAT locale ->
"public static final NumberFormat getInstance() Returns a general-purpose number format for the current default FORMAT locale."
In my case, this means that a score of "73,400" is parsed to 73 (because "." and "," are switched in comparison to the US), which is obviously less than 20000.
By declaring a variable "private final Locale locale = Locale.US;" in Score.java and then modifying getAmount() like so:
public long getAmount() { try { return NumberFormat.getInstance(locale).parse(amountAsString).longValue(); } catch (ParseException e) { e.printStackTrace(); } return 0; }
I passed the tests and was able to build.
Btw, thanks for making such great tutorials. I wouldn't be able to solve something like this otherwise :-)
Manuel Klettke
25,324 PointsThe next Code Challenge fails for the same reason.
//Edit: They all do in this stage
1 Answer
Craig Dennis
Treehouse TeacherGreat catch Manuel Klettke ! Thanks for the tag Seth Kroger ! Great work!
This one is fixed now, re-download, and I'm working through the next challenges in this stage.
Sorry about that and thanks for speaking up, and figuring it out!
Seth Kroger
56,414 PointsSeth Kroger
56,414 PointsGood catch. Tagging Craig Dennis