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

Henrik Munk
Henrik Munk
2,817 Points

Regarding Java Bisics - beginning Java - Java Objerct - task 2 of 2

here at your homepage I have a challange https://teamtreehouse.com/library/java-objects-2/delivering-the-mvp/applying-a-discount-code

When I check work of this code

public void applyDiscountCode(String discountCode) { try{ this.discountCode = normalizeDiscountCode (discountCode); } catch ( IllegalArgumentException iae){ System.out.println("Invalid discount code"); } }

I get the following message;

Bummer: Hmmm...I ran order.applyDiscountCode("h1!") and I expected it to throw an IllegalArgumentException, but it didn't

When I check work of this code;

public void applyDiscountCode(String discountCode) { try{ this.discountCode = normalizeDiscountCode (discountCode); } catch ( IllegalArgumentException iae){ throw new IllegalArgumentException("Invalid discount code."); } }

I get the following message;

Hmmm...order.applyDiscountCode("$teal") threw an exception, when it shouldn't have

HMMMM - i do not see he fault - it is contridicting - can you give an explanation