목차
1. 슬롯머신 만들기(JAVA Applet)
1-1. 설정
1-2. 설계
1-3. 소스코드
1-4. 결과
2. 벽돌벽 그리기(JAVA Script)
2-1. 설정
2-2. 설계
2-3. 소스코드
2-4. 결과
1-1. 설정
1-2. 설계
1-3. 소스코드
1-4. 결과
2. 벽돌벽 그리기(JAVA Script)
2-1. 설정
2-2. 설계
2-3. 소스코드
2-4. 결과
본문내용
y = Math.abs (generator.nextInt())%10;
z = Math.abs (generator.nextInt())%10;
if (x==0 && y==0 && z==0)
{
System.out.println(\"Jackpot!!\");
point = 1000;
}
else if (x==y && x==z && y==z)
{
System.out.println(\"Three Number : \" + x);
point = x*10;
}
else if (x==y || x==z)
{
System.out.println(\"Two Number : \" + x);
point = x*10;
}
else if (y==z)
{
System.out.println(\"Two Number : \" + y);
point = y*10;
}
else
{
System.out.println(\"No point\");
point = 0;
}
score += point;
System.out.println (\" [ \" + x + \" ] [ \" + y + \" ] [ \" + z + \" ]\");
System.out.println (\"\\n\\n\");
System.out.println (\"Get Point(s) : \" + point);
System.out.println (\"Total Point(s) : \" + score);
System.out.println (\"\\n\\n\");
if (score > 0)
{
System.out.print (\"Continue Games ? (Y/N) :\");
str = Keyboard.readString();
}
else
{
System.out.println (\"Game Over!!\");
str = \"n\";
}
}
}
}
1) 무득점일 경우
2) 점수를 얻을 경우
3 ) 점수가 전부 소진될 경우
4) 사용자가 임의로 게임을 종료
3. 19 ) 벽돌로 된 벽의 패턴 그리기
1. 설정
1) 전체 화면은 400 x 400으로 한다.
2) 벽돌 하나의 크기는 20 x 10으로 한다.
3) 벽돌의 각 행은 그 위와 아래에 위치한 행들과는 중심이 어긋나 있다.
2. 설계
배경색 : orange
int width = 0, height = 0;
int i, j;
i를 40번 실행
for ( i=1이고 i가 41보다 작으면, i는 1씩 증가)
{
j를 21번 실행
for ( j=0이고 j가 21보다 작으면, j는 1씩 증가)
{
만약, i가 짝수이면,
page.drawRect (width, height, 20, 10);
width+=20;
i가 홀수이면
page.drawRect (width-10, height, 20, 10);
width+=20;
}
행이 바뀌면 height값 증가, width값은 초기화
width=0;
height+=10;
}
3. 소스코드
import java.applet.Applet;
import java.awt.*;
public class Block extends Applet
{
public void paint (Graphics page)
{
setBackground (Color.orange);
int width = 0, height = 0;
int i, j;
page.setColor (Color.black);
for ( i=1; i<41; i++ )
{
for ( j=0; j<21; j++ )
{
if (i%2==0)
{
page.drawRect (width, height, 20, 10);
width+=20;
}
else
{
page.drawRect (width-10, height, 20, 10);
width+=20;
}
}
width=0;
height+=10;
}
}
}
z = Math.abs (generator.nextInt())%10;
if (x==0 && y==0 && z==0)
{
System.out.println(\"Jackpot!!\");
point = 1000;
}
else if (x==y && x==z && y==z)
{
System.out.println(\"Three Number : \" + x);
point = x*10;
}
else if (x==y || x==z)
{
System.out.println(\"Two Number : \" + x);
point = x*10;
}
else if (y==z)
{
System.out.println(\"Two Number : \" + y);
point = y*10;
}
else
{
System.out.println(\"No point\");
point = 0;
}
score += point;
System.out.println (\" [ \" + x + \" ] [ \" + y + \" ] [ \" + z + \" ]\");
System.out.println (\"\\n\\n\");
System.out.println (\"Get Point(s) : \" + point);
System.out.println (\"Total Point(s) : \" + score);
System.out.println (\"\\n\\n\");
if (score > 0)
{
System.out.print (\"Continue Games ? (Y/N) :\");
str = Keyboard.readString();
}
else
{
System.out.println (\"Game Over!!\");
str = \"n\";
}
}
}
}
1) 무득점일 경우
2) 점수를 얻을 경우
3 ) 점수가 전부 소진될 경우
4) 사용자가 임의로 게임을 종료
3. 19 ) 벽돌로 된 벽의 패턴 그리기
1. 설정
1) 전체 화면은 400 x 400으로 한다.
2) 벽돌 하나의 크기는 20 x 10으로 한다.
3) 벽돌의 각 행은 그 위와 아래에 위치한 행들과는 중심이 어긋나 있다.
2. 설계
배경색 : orange
int width = 0, height = 0;
int i, j;
i를 40번 실행
for ( i=1이고 i가 41보다 작으면, i는 1씩 증가)
{
j를 21번 실행
for ( j=0이고 j가 21보다 작으면, j는 1씩 증가)
{
만약, i가 짝수이면,
page.drawRect (width, height, 20, 10);
width+=20;
i가 홀수이면
page.drawRect (width-10, height, 20, 10);
width+=20;
}
행이 바뀌면 height값 증가, width값은 초기화
width=0;
height+=10;
}
3. 소스코드
import java.applet.Applet;
import java.awt.*;
public class Block extends Applet
{
public void paint (Graphics page)
{
setBackground (Color.orange);
int width = 0, height = 0;
int i, j;
page.setColor (Color.black);
for ( i=1; i<41; i++ )
{
for ( j=0; j<21; j++ )
{
if (i%2==0)
{
page.drawRect (width, height, 20, 10);
width+=20;
}
else
{
page.drawRect (width-10, height, 20, 10);
width+=20;
}
}
width=0;
height+=10;
}
}
}
소개글