[src]
import CSLib.*;
import java.awt.*;
public class Array2D
{
static char[][] o =
{ {' ',' ',' ',' ',' ',' '},
{' ',' ','#','#',' ',' '},
{' ','#',' ',' ','#',' '},
{' ','#',' ',' ','#',' '},
{' ','#',' ',' ','#',' '},
{' ','#',' ',' ','#',' '},
{' ','#',' ',' ','#',' '},
{' ',' ','#','#',' ',' '}};
static char[][] one =
{ {' ',' ',' ',' ',' ',' '},
{' ',' ',' ','#',' ',' '},
{' ',' ','#','#',' ',' '},
{' ',' ',' ','#',' ',' '},
{' ',' ',' ','#',' ',' '},
{' ',' ',' ','#',' ',' '},
{' ',' ',' ','#',' ',' '},
{' ',' ','#','#','#',' '}};
char[][] two =
{ {' ',' ',' ',' ',' ',' '},
{' ',' ','#','#',' ',' '},
{' ','#',' ',' ','#',' '},
{' ',' ',' ',' ','#',' '},
{' ',' ',' ','#',' ',' '},
{' ',' ','#',' ',' ',' '},
{' ','#',' ',' ','#',' '},
{' ','#','#','#','#',' '}};
char[][] three =
{ {' ',' ',' ',' ',' ',' '},
{' ',' ','#','#',' ',' '},
{' ','#',' ',' ','#',' '},
{' ',' ',' ',' ','#',' '},
{' ',' ',' ','#',' ',' '},
{' ',' ',' ',' ','#',' '},
{' ','#',' ',' ','#',' '},
{' ',' ','#','#',' ',' '}};
char[][] four =
{ {' ',' ',' ',' ',' ',' '},
{' ',' ',' ','#','#',' '},
{' ',' ',' ','#','#',' '},
{' ',' ','#',' ','#',' '},
{' ',' ','#',' ','#',' '},
{' ','#',' ',' ','#',' '},
{' ','#','#','#','#','#'},
{' ',' ',' ',' ','#',' '}};
char[][] five =
{ {' ',' ',' ',' ',' ',' '},
{' ','#','#','#','#',' '},
{' ','#',' ',' ',' ',' '},
{' ','#',' ',' ',' ',' '},
{' ','#','#','#',' ',' '},
{' ',' ',' ',' ','#',' '},
{' ',' ',' ',' ','#',' '},
{' ','#','#','#',' ',' '}};
char[][] six =
{ {' ',' ',' ',' ',' ',' '},
{' ',' ','#','#',' ',' '},
{' ','#',' ',' ','#',' '},
{' ','#',' ',' ',' ',' '},
{' ','#','#','#',' ',' '},
{' ','#',' ',' ','#',' '},
{' ','#',' ',' ','#',' '},
{' ',' ','#','#',' ',' '}};
char[][] seven =
{ {' ',' ',' ',' ',' ',' '},
{' ','#','#','#','#',' '},
{' ','#',' ',' ','#',' '},
{' ',' ',' ',' ','#',' '},
{' ',' ',' ','#',' ',' '},
{' ',' ',' ','#',' ',' '},
{' ',' ',' ','#',' ',' '},
{' ',' ',' ','#',' ',' '}};
char[][] eight =
{ {' ',' ',' ',' ',' ',' '},
{' ',' ','#','#',' ',' '},
{' ','#',' ',' ','#',' '},
{' ','#',' ',' ','#',' '},
{' ',' ','#','#',' ',' '},
{' ','#',' ',' ','#',' '},
{' ','#',' ',' ','#',' '},
{' ',' ','#','#',' ',' '}};
char[][] nine =
{ {' ',' ',' ',' ',' ',' '},
{' ',' ','#','#',' ',' '},
{' ','#',' ',' ','#',' '},
{' ','#',' ',' ','#',' '},
{' ',' ','#','#','#',' '},
{' ',' ',' ',' ','#',' '},
{' ','#',' ',' ','#',' '},
{' ',' ','#','#',' ',' '}};
static int k=0;
void draw(char c[][], DrawingBox d){
for(int i=0;i<8;i++){
for(int j=0;j<6;j++){
if (c[i][j] == '#') d.fillRect(10*(j+k),i*10,10,10);
else d.drawRect(10*(j+k),i*10,10,10);
}}
k+=6;
}
void getData(InputBox in,DrawingBox d){
in.setPrompt("Input the interger : ");
String data = in.readString();
for(int z=0;z<data.length();z++){
switch(data.charAt(z)){
case '0' : draw(o,d);break;
case '1' : draw(one,d);break;
case '2' : draw(two,d);break;
case '3' : draw(three,d);break;
case '4' : draw(four,d);break;
case '5' : draw(five,d);break;
case '6' : draw(six,d);break;
case '7' : draw(seven,d);break;
case '8' : draw(eight,d);break;
case '9' : draw(nine,d);break;
}
}
}
public static void main(String args[]){
InputBox in=new InputBox("Enter Data");
Array2D a2=new Array2D();
DrawingBox d=new DrawingBox("xXx");
a2.getData(in,d);
}
}
[/src]