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 trialMarzoog AlGhazwi
15,796 PointsI don't know how to solve this challenge can someone help me
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> usdToArgentinePesoConverterAndFormatter =
usdToArgentinePesoConverter.andThen(argentineCurrencyFormatter);
return getConvertedPriceStatements(records,
// TODO: Correct this. It should to convert AND format. However, there is room parameter wise for only one Function...hmmm.
usdToArgentinePesoConverterAndFormatter);
}
Tests failed
java.lang.AssertionError:
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 (Argentine Peso)"
1 Answer
Brendan Whiting
Front End Web Development Techdegree Graduate 84,738 PointsYour code looks good. I pasted it in and it passed all the tests locally for me, and passed the tests after I uploaded it.
In your failing test, there's an extra space being added between the dollar sign and the number in the Argentinian peso ($15,48 vs $ 15,48). I'm not sure why, but in the history of questions on this topic it seems like there might be an issue with the locale, depending on where you are in the world. Try uploading your code anyway even if the tests aren't passing locally.