Java problem

Associate
Joined
1 Jan 2010
Posts
1,021
Hey guys,

Programming in Java I have to design an object that you would buy from a vending machine. I've got a chocolate bar, just a standard magenta rectangle, if you invoke the method "unwrap" I made it changes colour as if to unwrap it.

Now I want to somehow have a method that when invokes it essentially "eats" the chocolate bar, erasing it off the page. BUT, I want to do this so that it is not possible to eat it if it isn't unwrapped, and somehow have a way of querying if it is edible (aka is it unwrapped) is this at all possible?
 
Back
Top Bottom