Complete the ZombiePlant practice problem before reviewing the solution.
Review the ZombiePlant solution with AP CS Tutor Brandon Horn.
Note: This is a new practice problem. Please report any issues with a comment or my contact form. Thanks.
public class ZombiePlant { private final int maxPotency; private int treatmentsNeeded; public ZombiePlant(int max, int needed) { maxPotency = max; treatmentsNeeded = needed; } public int treatmentsNeeded() { return treatmentsNeeded; } public void treat(int potency) { if(potency > maxPotency) { treatmentsNeeded++; } else { if(treatmentsNeeded > 0) treatmentsNeeded--; } } public boolean isDangerous() { return treatmentsNeeded > 0; } }