Is there anything wrong with my logic? I can't seem to pass both these requirements "Nobody ate the pie. The wolf ate a little", I either pass this one "Nobody ate the pie" or none at all, I tried adding and removing the pie, creating a new ArrayList to simulate that it was carried in a basket, nothing works.
package en.codegym.task.jdk13.task09.task0924;
import java.util.ArrayList;
/*
A scary fairy tale
*/
public class Solution {
public static RedRidingHood hood = new RedRidingHood();
public static Grandmother grandmother = new Grandmother();
public static Pie pie = new Pie();
public static Woodcutter woodcutter = new Woodcutter();
public static Wolf wolf = new Wolf();
public static void main(String[] args) {
ArrayList<StoryItem> carriedItems = new ArrayList<>();
carriedItems.add(pie); // The pie is carried by the wolf
wolf.ate.addAll(carriedItems); // The wolf ate the carried items
wolf.killed.add(grandmother); // The wolf killed the grandmother
woodcutter.killed.add(wolf); // The woodcutter killed the wolf
// Remove the pie from the ate ArrayList to simulate eating a little
wolf.ate.remove(pie);
// Add the pie again to the ate ArrayList to represent eating a little
wolf.ate.add(pie);
}
// Red riding hood
public static class RedRidingHood extends StoryItem {
}
// Grandmother
public static class Grandmother extends StoryItem {
}
// Pie
public static class Pie extends StoryItem {
}
// Woodcutter
public static class Woodcutter extends StoryItem {
}
// Wolf
public static class Wolf extends StoryItem {
}
public static abstract class StoryItem {
public ArrayList<StoryItem> killed = new ArrayList<>();
public ArrayList<StoryItem> ate = new ArrayList<>();
}
}