자바 체스 와 중국 장기 판 그리 기
1.중국 장기 바둑판 코드
import java.awt.Font;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
public class ChineseChese extends Frame{
public ChineseChese(){
setSize(630,630);
this.setVisible(true);
addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
});
}
public void paint(Graphics g){
Font f=new Font(" ",Font.BOLD,30);
g.setFont(f);
int length=60;
g.drawRect(60, 50,500, 560); //
g.drawRect(70, 60, 480, 540);
/* */
for(int i=0;i<9;i++){
g.drawLine(70, length, 550, length);
length+=60;
/* */
g.drawString(" ", 130, 350);
g.drawString(" ",400 , 350);
}
length=130;
/* */
for(int i=0;i<7;i++){
g.drawLine( length,60, length,300);
length+=60;
}
/* */
length=130;
for(int i=0;i<7;i++){
g.drawLine( length,360, length,600);
length+=60;
}
/* */
g.drawLine(250, 60, 370, 180);
g.drawLine(370, 60, 250, 180);
/* */
g.drawLine(250, 480, 370, 600);
g.drawLine(250, 600, 370, 480);
}
public static void main(String args[]){
new ChineseChese();
}
}
2.체스 코드
import java.applet.Applet;
import java.awt.Graphics;
public class ChessBoard extends Applet{
public void init(){
setSize(400,400);
this.setVisible(true);
}
public void paint(Graphics g){
g.drawRect(20, 10, 320, 320);
g.drawLine(60, 10, 60, 330); // ;
g.drawLine(100,10,100,330); // ;
g.drawLine(140, 10, 140, 330); // ;
g.drawLine(180, 10, 180, 330);
g.drawLine(220,10,220,330);
g.drawLine(260, 10, 260, 330);
g.drawLine(300,10,300,330);
// g.drawLine(340,10,340,330);
/* */
g.drawLine(20,50,340,50); // ;
g.drawLine(20,90,340,90);
g.drawLine(20,130,340,130);
g.drawLine(20,170,340,170);
g.drawLine(20,210,340,210);
g.drawLine(20,250,340,250);
g.drawLine(20,290,340,290);
/* */
g.fillRect(20, 10,40, 40);
g.fillRect(100, 10,40, 40);
g.fillRect(180, 10,40, 40);
g.fillRect(260, 10,40, 40);
g.fillRect(60, 50,40, 40);
g.fillRect(140, 50,40, 40);
g.fillRect(220, 50,40, 40);
g.fillRect(300, 50,40, 40);
g.fillRect(20, 90,40, 40);
g.fillRect(100, 90,40, 40);
g.fillRect(180, 90,40, 40);
g.fillRect(260, 90,40, 40);
g.fillRect(60, 130,40, 40);
g.fillRect(140, 130,40, 40);
g.fillRect(220, 130,40, 40);
g.fillRect(300, 130,40, 40);
g.fillRect(20, 170,40, 40);
g.fillRect(100, 170,40, 40);
g.fillRect(180, 170,40, 40);
g.fillRect(260, 170,40, 40);
g.fillRect(60, 210,40, 40);
g.fillRect(140, 210,40, 40);
g.fillRect(220, 210,40, 40);
g.fillRect(300, 210,40, 40);
g.fillRect(20, 250,40, 40);
g.fillRect(100, 250,40, 40);
g.fillRect(180, 250,40, 40);
g.fillRect(260, 250,40, 40);
g.fillRect(60, 290,40, 40);
g.fillRect(140, 290,40, 40);
g.fillRect(220, 290,40, 40);
g.fillRect(300, 290,40, 40);
}
중국 장기 바둑판 효과 도체스 효과 도
이상 이 바로 본 고의 모든 내용 입 니 다.여러분 의 학습 에 도움 이 되 고 저 희 를 많이 응원 해 주 셨 으 면 좋 겠 습 니 다.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Is Eclipse IDE dying?In 2014 the Eclipse IDE is the leading development environment for Java with a market share of approximately 65%. but ac...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.