I need help on an assignment I have. The first part was to write a program that would declare an array with 150 elements, assign the "#" symbol to each element, then print the elements in such a way that it would spell a letter (in this case, "A") within a 10x15 grid pattern. The elements used to write the letter would be filled with a blank. That was easy. However, the second part requires me to create an applet in which I draw a rectangular grid with 15x10 grid (each cell being 10x10 pixels). Each cell is supposed to correspond to one element in the array. If there is a pound sign in the array element, the cell should be blue and filled. If there is a space in the array element, the cell should be blue and unfilled (the cell should appear white, the default applet backgroud color). I'm also supposed to use the code I used in the first part of the assignment. I have no trouble creating a grid, but corresponding a blue square with the "#" is something I'm not able to figure out... an example of what my instructor wants is here:http://i907.photobucket.com/albums/ac280/bluesilver89/csproject.jpg
Here's the code I have so far for the second part of my assignment:
import javax.swing.JApplet;
import java.awt.*;
public class Lab8b extends JApplet
{
public void paint(Graphics g)
{
char letterShape[] = new char[150];
for (int i = 0; i < letterShape.length; i++)
{
letterShape[i] = '#';
}
letterShape[25] = ' ';
letterShape[26] = ' ';
letterShape[32] = ' ';
letterShape[35] = ' ';
letterShape[36] = ' ';
letterShape[43] = ' ';
letterShape[44] = ' ';
letterShape[47] = ' ';
letterShape[54] = ' ';
letterShape[57] = ' ';
letterShape[63] = ' ';
letterShape[68] = ' ';
letterShape[73] = ' ';
letterShape[78] = ' ';
letterShape[79] = ' ';
letterShape[83] = ' ';
letterShape[84] = ' ';
letterShape[85] = ' ';
letterShape[86] = ' ';
letterShape[87] = ' ';
letterShape[88] = ' ';
letterShape[93] = ' ';
letterShape[98] = ' ';
letterShape[100] = ' ';
letterShape[102] = ' ';
letterShape[109] = ' ';
letterShape[110] = ' ';
letterShape[112] = ' ';
letterShape[119] = ' ';
letterShape[120] = ' ';
letterShape[121] = ' ';
letterShape[122] = ' ';
letterShape[128] = ' ';
letterShape[129] = ' ';
for (int x = 0; x <= 90; x = x + 10)
{
for (int y = 0; y <= 140; y = y + 10)
{
g.drawRect(x, y, 10, 10);
} // end for
} // end for
} // end main
} // end class
I'd greatly appreciate any help - I suspect it involves the use of a loop, or possibly modifying the array, but I'm not sure.