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 trialTan Yang
13,163 PointsI can't pass this challenge, please help!
public static List<String> getPricesConvertedForArgentina(List<HousingRecord> records) { Locale argLocale = Locale.forLanguageTag("es-AR"); // This fluctuates and is hardcoded temporarily BigDecimal argPesoToUsdRate = new BigDecimal("15.48");
// TODO: These functions are in working order, but separately they don't match the single Function signature expected
Function<Integer, BigDecimal> usdToArgentinePesoConverter = usd -> argPesoToUsdRate.multiply(new BigDecimal(usd));
Function<BigDecimal, String> argentineCurrencyFormatter = price -> {
Currency currentCurrency = Currency.getInstance(argLocale);
NumberFormat currencyFormatter =
NumberFormat.getCurrencyInstance(argLocale);
return String.format("%s (%s)",
currencyFormatter.format(price),
currentCurrency.getDisplayName()
);
};
Function<Integer, String> testConverter = usdToArgentinePesoConverter.andThen(argentineCurrencyFormatter);
return getConvertedPriceStatements(records, testConverter
// TODO: Correct this. It should to convert AND format. However, there is room parameter wise for only one Function...hmmm.
//homeValueIndex -> "FIXME!!!"
);
}
1 Answer
Gergely Horvath
Courses Plus Student 8,207 PointsLooks like "argentin peso" got translated to your language. You may try switching
currentCurrency.getDisplayName()
to this
currentCurrency.getDisplayName(Locale.forLanguageTag("en-US"))
Read more here.
Tan Yang
13,163 PointsOh, thank you so much! I was stuck there, but I am wondering why it translated to my language...??
Gergely Horvath
Courses Plus Student 8,207 PointsI guess the code wasn't ready for the possibility that currency name displays on languages other than english. As the stackoverflow post says localization isn't necessarily there. So chances are this doesn't happen to most users facing this challange. Keep on going! :)
Tan Yang
13,163 PointsThanks for explaining!
Tan Yang
13,163 PointsTan Yang
13,163 Pointsthe result is : Expected: iterable containing ["First is $1.00 (USD) which is $15,48 (Argentine Peso)", "Second is $2.00 (USD) which is $30,96 (Argentine Peso)"] but: item 0: was "First is $1.00 (USD) which is $15,48 (้ฟๆ นๅปทๆฏ็ดข)"