java - boolean method passed through a string to return either true or false -
Depending on what is in the string, I must use a boolean to get the right or wrong back. If there is a "penny" in the list, then it is considered to be a false return, but I can not seem to do this. Any suggestions or things that I'm messing up?
Public square wallet {Private array list & lt; String & gt; List = New Arrestist & lt; String & gt; (); Public stationary zero main (string [] args) {wallet c = new purse (); Scanner input = new scanner (System.in); C.addCoin ("Quarter"); C.addCoin ("coins"); C.addCoin ("nick"); C.addCoin ("Money"); Println (c.toString ()); } Public Zero addCoin (string coin name) {list.add (name of coin); } Public Boolean Search Koyna (string coinnation) {if (list.contains ("penny")) {return false; } And {return true; }} Public string toString () {return.getClass (). GetCanonicalName () + list.toString (); }}
You need to find the method that will determine the boolean value.
Then call it like this:
if (findCoin ("mycoin")) {System.out.println (c.toString ()); }
Along with this, you can also define the scanner so that you can read it and ask the user to read it.
Comments
Post a Comment