// Arup Guha
// 4/6/2010
// 2008 AP Free Response Question #4C Solution

public class NotChecker implements Checker {
	
	private Checker criterion;
	
	public NotChecker(Checker a) {
		criterion = a;
	}

	// The question didn't ask to write this, but I need it to test out
	// the code for the solution.	
	public boolean accept(String text) {
		return !criterion.accept(text);
	}
	
	public static void main(String[] args) {
		
		// They gave us this.
		Checker aChecker = new SubstringChecker("artichokes");
		Checker kChecker = new SubstringChecker("kale");
		
		// This single line is the answer to the question.
		Checker yummyChecker = new AndChecker(new NotChecker(aChecker), new NotChecker(kChecker));
		
		// These are the three test cases they have. They really aren't sufficient.
		if (yummyChecker.accept("chocolate truffles"))
			System.out.println("We accepted chocolate truffules.");
		
		if (!yummyChecker.accept("kale is great"))
			System.out.println("I found the kale - bad!");
			
		if (!yummyChecker.accept("Yuck: artichokes & kale"))
			System.out.println("Found both offending objects!");
			
		// Three more cases testing boundary conditions.
		if (!yummyChecker.accept("Where are the blahartichokessss?"))
			System.out.println("Still found it.");
			
		if (!yummyChecker.accept("So there simply isn't a lot of kale"))
			System.out.println("Still found kale...");
			
		if (yummyChecker.accept("here is a misspelling: kalie, or artichokse."))
			System.out.println("No bad stuff here.");
	}
}