[15 pts] Define a class PigPen for tracking the number
of pigs in in a pen. It should support the following methods.
public class PigPenTest { public static void run() { PigPen pen = new PigPen(2); pen.pigExits(); IO.println(pen.isEmpty()); // prints ``false'' pen.pigExits(); IO.println(pen.isEmpty()); // prints ``true'' pen.pigEnters(); IO.println(pen.isEmpty()); // prints ``false'' } }
public class PigPen { private int count; public PigPen(int pigs) { count = pigs; } public boolean isEmpty() { return count == 0; } public void pigEnters() { count++; } public void pigExits() { count--; } }