A. java中国象棋游戏编程中如何分别设置好象棋的选定以及对象棋进行移动
面向对象的编程的多态性咯~
写一个棋类,然后子类继承的时候重写MOVE方法。
B. 用JAVA写象棋代码,炮的规则和车的规则怎么写 这题没有钱的 我发错了
车的规则就是 目标点 不能超过前面的第一个人。
炮的规则就是 目标点 必须超过前面的第一个 不超过前面的第二个人。
C. chinesechess游戏中没有道具怎么办
chinesechess游戏是需要去购买道具。
游戏介绍:
象棋,亦作“象碁”、中国象棋(英文名Chinese chess),中国传统棋类益智游戏,在中国有着悠久的历史,先秦时期已有记载。
属于二人对抗性游戏的一种,由于用具简单,趣味性强,成为流行极为广泛的棋艺活动。主要流行于华人及汉字文化圈的国家,象棋是中国正式开展的78个体育运动项目之一,是首届世界智力运动会的正式比赛项目之一。
一个中国象棋的java实现程序。中国象棋在中国有着悠久的历史,属于二人对抗性游戏的一种。本例将使用java来演示如何创建一个中国象棋游戏。
象棋,中国象棋(英文名Chinese chess),中国传统棋类益智游戏,在中国有着悠久的历史,先秦时期已有记载。属于二人对抗性游戏的一种,由于用具简单,趣味性强,成为流行极为广泛的棋艺活动。
D. java编程实现中国象棋中马的走位以及输出。
简化一下,假设马不走回头路,一直向右
public class ChessHorse
{
static final int X=8;
static final int Y=4;
public void gossip(int x,int y)
{
while((x<=X)&&(y<=Y))
{
System.out.println("("+x+","+y+")");
x+=2;
y++;
}
}
public static void main(String[] args)
{
ChessHorse horse=new ChessHorse();
System.out.println("马的走位:");
horse.gossip(0,0);
}
}
E. 在网上了一段中国象棋的java源代码,可是总出现错误,错误是指向类,说的是找不到符号,求解
把代码错误提示贴出来,还有这些大部分是找不到JAR文件导致
以免其他原因请把中文改成英文
找不到符号基本是找不到引用的类
F. java怎么编写中国象棋
这个属于java.swing里面的知识,只要学了,在加一点点算法就可以弄出来。
G. 给出中国象棋的棋盘 用java代码描述“x”的走法
如果你有点编程基础的话 我就不罗嗦了
棋盘自然是二维数组了 你用什么方法存储自己选了
不知道你说的X 是啥东西 如果是象 那我说说吧
以前我也考虑过做象棋的游戏
首先象的行走为 对角线
对角线的特点就是 横纵坐标的值操作相同 即加或者减 都为相同的数 比如 X+2 Y-2
以XY坐标系来说
象有4个方向可以走 假设当前的象处在 0点 也就是原点 那么四个方向 分别是
1 . X+2 Y+2
2. X-2 y+2
3. X+2 Y-2
4. X-2 Y-2
以此种方式可以知道 它所移动的方向是什么
比如 当前为 0,0 如果 它要移动到坐标2,2 则说明想方向1去移动了
判断移动方向后 判断是否有别腿现象
当然 就是不是+2的位置 而是+1的位置
比如要移动到X+2 Y+2 则判断 X+1 y+1的位置是否有棋子
好了 说这么多 不知道你明白不 哎...
H. java象棋登录界面的代码
你可参考:http://..com/question/127345147.html?qbl=relate_question_0&word=java%CF%F3%C6%E5%B5%C7%C2%BC%BD%E7%C3%E6%B5%C4%B4%FA%C2%EB
还有这个;
package java1;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.Rectangle;
import java.awt.Font;
public class login extends JFrame
{
public login() {
try {
jbInit();
}
catch (Exception ex) {
ex.printStackTrace();
}
}
public static void main(String[] args)
{
login frm=new login();
frm.setBounds(300,200,300,260);
frm.setVisible(true);
}
private void jbInit() throws Exception {
this.getContentPane().setLayout(null);
jLabel1.setForeground(Color.red);
jLabel1.setText("用户名");
jLabel1.setBounds(new Rectangle(25, 72, 68, 29));
jButton2.setBounds(new Rectangle(142, 159, 81, 30));
jButton2.setText("取消");
jButton2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
jButton2_actionPerformed(e);
}
});
jButton1.setBounds(new Rectangle(38, 159, 81, 29));
jButton1.setText("确定");
jButton1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
jButton1_actionPerformed(e);
}
});
jTextField1.setBounds(new Rectangle(109, 79, 136, 23));
jPasswordField1.setBounds(new Rectangle(109, 115, 136, 23));
this.getContentPane().add(jLabel1);
jLabel3.setFont(new java.awt.Font("隶书", Font.PLAIN, 24));
jLabel3.setText("学 生 考 试 系 统");
jLabel3.setBounds(new Rectangle(22, 15, 268, 47));
this.getContentPane().add(jTextField1);
this.getContentPane().add(jLabel2);
this.getContentPane().add(jButton2);
this.getContentPane().add(jButton1);
this.getContentPane().add(jLabel3);
this.getContentPane().add(jPasswordField1);
jLabel2.setForeground(Color.red);
jLabel2.setText("密码");
jLabel2.setBounds(new Rectangle(26, 112, 68, 29));
}
JLabel jLabel1 = new JLabel();
JLabel jLabel2 = new JLabel();
JTextField jTextField1 = new JTextField();
JButton jButton1 = new JButton();
JButton jButton2 = new JButton();
JLabel jLabel3 = new JLabel();
JPasswordField jPasswordField1 = new JPasswordField();
main2 wo=new main2();
int sum;
//判断权限的方法
public void success()
{
try{
ResultSet rs1;
String s1="select * from 管理权限 where name='"+jTextField1.getText()+"' and password='"+jPasswordField1.getText()+"'";
rs1=sqlcx.Rs_jiluji(s1);
rs1.first();
sum=Integer.parseInt((String)(rs1.getString(3)));
System.out.println(sum);
very();
}
catch(Exception c)
}
//根据权限设置窗口
public void very()
{
if (sum==1)
{JOptionPane.showOptionDialog(this, "您现在是以教师权限登陆", "登陆信息"
, JOptionPane.DEFAULT_OPTION,
JOptionPane.ERROR_MESSAGE,
null, null, null);
}
else
{
JOptionPane.showOptionDialog(this, "你现在是以学生权限登陆", "登陆信息"
, JOptionPane.DEFAULT_OPTION,
JOptionPane.ERROR_MESSAGE,
null, null, null);
wo.jButton2.setVisible(false);
wo.jButton3.setVisible(false);
wo.jButton4.setVisible(false);
wo.jButton5.setVisible(false);
wo.jButton6.setVisible(false);
wo.jButton7.setVisible(false);
wo.jButton8.setVisible(false);
wo.jMenu2.setVisible(false);
wo.jMenu3.setVisible(false);
wo.jMenu4.setVisible(false);
}
}
public void jButton1_actionPerformed(ActionEvent e)
{
//判断用户名是否为空
if (jTextField1.getText().length() == 0) {
JOptionPane.showOptionDialog(this, "用户名不能为空", "错误信息"
, JOptionPane.DEFAULT_OPTION,
JOptionPane.ERROR_MESSAGE,
null, null, null);
}
//判断密码是否为空
else if (jPasswordField1.getText().length()==0)
{
JOptionPane.showOptionDialog(this,"密码不能为空", "错误信息"
, JOptionPane.DEFAULT_OPTION,
JOptionPane.ERROR_MESSAGE,
null, null, null);
}
else
{
try
{
ResultSet rs;//声明记录集
String sql="select * from 管理权限 where name='"+jTextField1.getText()+"'";
rs = sqlcx.Rs_jiluji(sql);
if (rs.next())
{
if(jPasswordField1.getText().equals(rs.getString(2)))
{
success();
wo.setBounds(60,40,700,600);
wo.setVisible(true);
this.dispose();
}
else
{
JOptionPane.showOptionDialog(this,"密码错误", "错误信息"
, JOptionPane.DEFAULT_OPTION,
JOptionPane.ERROR_MESSAGE,
null, null, null);
}
}
else
{
JOptionPane.showOptionDialog(this,"没有所要找的用户名", "错误信息"
, JOptionPane.DEFAULT_OPTION,
JOptionPane.ERROR_MESSAGE,
null, null, null);
}
}
catch(Exception c){
JOptionPane.showOptionDialog(this,"连接数据库失败", "错误信息"
, JOptionPane.DEFAULT_OPTION,
JOptionPane.ERROR_MESSAGE,
null, null, null);
}
}
}
public void jButton2_actionPerformed(ActionEvent e) {
System.exit(0);
}
}
I. 求要中国象棋将,帅的走法的JAVA代码
int[][] loaction=new int[10][9];
左帅:loaction[0][4];
X X X
X X
X X X
-----
[0][3] [1][3] [2][3]
[0][4] [1][4] [2][4]
[0][5] [1][5] [2][5]
即:x>=0 && x<=2 && y>=3 && y<=5
------------------------------
右将:loaction[9][4];
X X X
X X
X X X
-----
[7][3] [8][3] [9][3]
[7][4] [8][4] [9][4]
[7][5] [8][5] [9][5]
---------------------------
public int go(int x,int y,int path,int len){
if(loaction[x][y]==1) {//是帅
if(path==1){//向左
if(x<=0) return -1;//返回-1代表走发错误
else {loaction[x-1][y]=1;loaction[x][y]=-1;}//将左一个格子标记为帅
}
else if(path==2){//向上
...
}
else if(path==3){//向右
...
}
else if(path==4){//向下
...
}//else path
}//if key
else if(loaction[x][x]==2){//2代表将
....
}//if key
}
车就差不多了
J. 中国象棋走法规则用Java怎么编程
我并不懂编程,但是还是希望以下答案对你有帮助!
棋盘自然是二维数组了 如果是象 那我说说吧以前我也考虑过做象棋的游戏首先象的行走为 对角线对角线的特点就是 横纵坐标的值操作相同 即加或者减 都为相同的数 比如 X+2 Y-2以XY坐标系来说象有4个方向可以走 假设当前的象处在 0点 也就是原点 那么四个方向 分别是1 . X+2 Y+22. X-2 y+23. X+2 Y-24. X-2 Y-2以此种方式可以知道 它所移动的方向是什么比如 当前为 0,0 如果 它要移动到坐标2,2 则说明想方向1去移动了判断移动方向后 判断是否有别腿现象 当然 就是不是+2的位置 而是+1的位置比如要移动到X+2 Y+2 则判断 X+1 y+1的位置是否有棋子