public class Feeder { /** * The amount of food, in grams, currently in the bird feeder; initialized in the constructor and * always greater than or equal to zero */ private int currentFood; public Feeder(int cf) { currentFood =cf;} /** * Simulates one day with numBirds birds or possibly a bear at the bird feeder, * as described in part (a) * Precondition: numBirds > 0 */ public void simulateOneDay(int numBirds) { /* to be implemented in part (a) */ } /** * Returns the number of days birds or a bear found food to eat at the feeder in this simulation, * as described in part (b) * Preconditions: numBirds > 0, numDays > 0 */ public int simulateManyDays(int numBirds, int numDays) { /* to be implemented in part (b) */ return -1; // remove to test your answer to part (b) } // There may be instance variables, constructors, or methods that are not shown. public String toString() { return currentFood +"g of food is left"; } public static void main(String[] args) { Feeder ex1 = new Feeder(500); Feeder ex2 = new Feeder(1000); Feeder ex3 = new Feeder(100); ex1.simulateOneDay(12); ex2.simulateOneDay(22); ex3.simulateOneDay(5); System.out.println("Part (a)"); System.out.println( " ex1.simulateOneDay(12) could result in 12 birds eating 20g of food each, leaving 260g of food"); for(int i=1; i< 6; i++) { ex1 = new Feeder(500); ex1.simulateOneDay(12); System.out.println("Your code returned " + ex1 ); } System.out.println( " ex2.simulateOneDay(22) could result in a bear eating all the food, leaving 0g of food"); System.out.println("Your code returned " + ex2 ); System.out.println( " ex3.simulateOneDay(5) could result in 5 birds attempting to eat 30g of food each a bear eating all the food, leaving 0g of food"); System.out.println("Your code returned " + ex3 ); System.out.println("Part (b)"); System.out.println( "current Food 2400, ex1.simulateOneDay(10, 4)"); ex1 = new Feeder(2400); System.out.println("Your code returned " + ex1.simulateManyDays(20,20) + " " + ex1 ); } }