Overloaded counters

343 views
Skip to first unread message

caseysc...@gmail.com

unread,
Apr 5, 2015, 7:19:01 PM4/5/15
to moo...@googlegroups.com
Hi,

I'm having problems with week 5 exercise 84.

I'm getting 62% complete, but it gives me the following error:

You returned wrong value. Try code:
Counter c = new Counter(2, true);
c.decrease();
c.decrease();
c.decrease();
System.out.println(c.value());
 expected:<0> but was:<-1>
The link to my work is here: PASTE TMC PASTEBIN LINK HERE




Best regards


Supported languages are English and Finnish

Please use our build in TMC Pastebin when asking questions related to your code  
 
TMC Plugin has built-in code sharing feature. 
In NetBeans, select TMC -> Send code to TMC pastebin. Copy the link you receive and paste it to your message.  

You may use our web interface to share code snippets: http://paste.mooc.fi

Jarmo Isotalo

unread,
Apr 6, 2015, 7:58:30 AM4/6/15
to caseysc...@gmail.com, moo...@googlegroups.com
When the counter is initialised so that check is true, it should make sure that the value remains positive or zero all the time.
Now you appear to have this functionality in the decrease method which takes a int parameter but not in the method which has no parameters.

--
http://mooc.fi
---
You received this message because you are subscribed to the Google Groups "mooc.fi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to moocfi+un...@googlegroups.com.
To post to this group, send email to moo...@googlegroups.com.
Visit this group at http://groups.google.com/group/moocfi.
To view this discussion on the web visit https://groups.google.com/d/msgid/moocfi/5d240c52-b8bf-4f17-8bb7-26235852faa0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages