/* Maze.java This assignment shows application and reinforces multi-dimensional arrays. by Nancy Reddig, Oracle Academy Instructor */ import java.awt.event.*; import java.awt.*; import java.awt.Graphics; // import class Graphics import javax.swing.JApplet; // import class JApplet class Maze { MazeManApplet parent; Maze(MazeManApplet p) { parent=p; } void drawMaze() { Graphics g=parent.getGraphics(); for(int i=0;i<20;i++) for(int j=0;j<16;j++) { switch(parent.matrix[j][i]) { case -1: g.setColor(Color.gray); g.fillRect(i*20,j*20,20,20); break; case 1: g.setColor(Color.black); g.fillRect(i*20,j*20,20,20); break; case 0: g.setColor(Color.white); g.fillRect(i*20,j*20,20,20); break; case 2: g.setColor(Color.black); g.fillRect(i*20,j*20,20,20); g.setColor(Color.white); g.fillOval(i*20+8,j*20+8,4,4); break; case 3: g.setColor(Color.black); g.fillRect(i*20,j*20,20,20); g.setColor(Color.white); g.fillOval(i*20+4,j*20+4,12,12); break; } } } }