Final Exam - Coding Practice
less than a minute
Note
You have 2 Gradescope assignments available. The specs and java files to start with are linked below.Problem 1 (18 points): Spell
boolean canISpell(int start, String candidates, String target)
Write method canISpell(int start, String candidates, String target)
for
this provided Spell class (DOWNLOAD IT HERE)
. Given a String candidates
and an int start
, is it possible to choose a group of some of the characters in candidates (from position start
onward), such that the group of characters can be concatenated to form the given target word? The caller can specify the whole String
simply by passing in 0
for start
. No loops are needed (and they will receive no points) – you must write a recursive solution. Return false
if any String
parameter is null
, or if start
is out of bounds.
canISpell(0, "qwertyuiop", "try") → true
canISpell(0, "qwertyuiop", "pie") → true
canISpell(0, "qwertyuiop", "quick") → false
canISpell(0, "qwertyuiop", "quit") → true
canISpell(1, "qwertyuiop", "quit") → false
Problem 2 - Forestry Management
Download the provided classes,
Forest.java
and
ManagedForest.java
. Implement the methods as described in ManagedForest.java
and submit only ManagedForest.java
. DO NOT change Forest.java
.
- ManagedForestTest.java is provided for your convenience in testing.