Question
*** as simple as possible using loops and conditions *** * canSpell - takes two parameters: a String representing the letters * on a set
*** as simple as possible using loops and conditions ***
* canSpell - takes two parameters: a String representing the letters * on a set of tiles, and a second String representing a word * The method tests to see if the word can be made from the * letters on the tiles (return true if it can, false otherwise). * You might have more than one tile with the same letter, * but you can only use each tile once. * * Hint: Each time you "use" a letter, remove it from the * tiles String. See the removeChar method. * * canSpell("WQXOACW","COW") --> true * canSpell("WQXOACW","PIG") --> false * canSpell("","PIG") --> false * canSpell("WESCQSI","") --> true * canSpell("","") --> true
removeChar - takes two parameters: a String representing the letters * on a set of tiles, and a single char to be removed from * those tiles. The method returns a String with one * occurrance of the char removed. * * NOTE: You can't "remove" a char from a String. You must build * a new String that does not contain the char. * * removeChar("WQXOACW",'C') --> "WQXOAW" * removeChar("WQXOAW",'O') --> "WQXAW" * removeChar("WQXAW",'W') --> "QXAW" * removeChar("QXAW",'T') --> "QXAW" (did not remove T because it was not there)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started