import javax.microedition.lcdui.*; import java.util.*; class EggContainer{ double xAxisMultiplier; double yAxisMultiplier; Catcher catcher=null; PointCounter pointCounter=null; Vector eggs = new Vector(); Random randomizer = new Random(); int[][][] coordinates={ // top left { {1,2, 2,2}, {3,4, 2,2}, {5,6, 2,2}, {7,8, 2,2}, {9,10, 2,2}, {11,12, 2,2}, {11,19, 2,2}, {11,26, 2,2}, {11,33, 2,2}, {11,40, 2,2} }, // top right { {46,2, 2,2}, {44,4, 2,2}, {42,6, 2,2}, {40,8, 2,2}, {38,10, 2,2}, {36,12, 2,2}, {36,19, 2,2}, {36,26, 2,2}, {36,33, 2,2}, {36,40, 2,2} }, // bottom left { {1,16, 2,2}, {3,18, 2,2}, {5,20, 2,2}, {7,22, 2,2}, {9,24, 2,2}, {11,26, 2,2}, {11,33, 2,2}, {11,40, 2,2} }, // bottom right { {46,16, 2,2}, {44,18, 2,2}, {42,20, 2,2}, {40,22, 2,2}, {38,24, 2,2}, {36,26, 2,2}, {36,33, 2,2}, {36,40, 2,2} } }; int[][] leftSplash={ {10,48,9,46}, {9,46,11,47}, {11,47,11,45}, {11,45,12,47}, {12,47,14,46}, {14,46,12,48}, {12,48,10,48} }; int[][] rightSplash={ {36,48,35,46}, {35,46,37,47}, {37,47,37,45}, {37,45,38,47}, {38,47,40,46}, {40,46,38,48}, {38,48,36,48} }; public EggContainer(Catcher eggCatcher, PointCounter pCounter, int width, int height) { catcher=eggCatcher; pointCounter=pCounter; xAxisMultiplier=(double)width/50.0; yAxisMultiplier=(double)height/50.0; translateEggCoordinates(); translateCoordinates(leftSplash); translateCoordinates(rightSplash); // add one egg eggs.addElement(new Egg(randomizer.nextInt(4))); } public void drawEggState(Graphics g, int position, int state) { if (Egg.stateIsBroken(position, state)) { if (position==EggPosition.UP_LEFT || position==EggPosition.DOWN_LEFT) { drawLines(g, leftSplash); } else { drawLines(g, rightSplash); } } else { drawOval(g, coordinates[position][state]); } } public void drawEgg(Graphics g, Egg egg) { if (egg.isDismissed()) { // erase previous g.setColor(255,255,255); drawEggState(g, egg.position, egg.oldState); } else { // erase previous g.setColor(255,255,255); drawEggState(g, egg.position, egg.oldState); // draw new g.setColor(0,0,0); drawEggState(g, egg.position, egg.state); } } public void draw(Graphics g) { // loop through all eggs for (int i=0; i