java蜘蛛纸牌游戏源代码
}
}
}
}
/**
**返回值:boolean
**方法:判断card是否是正面
*/
public boolean isCardFront(){
return this.isFront;
}
/*
**返回值:boolean
**方法:返回是否能够移动
*/www.youerw.com
public boolean isCardCanMove(){
return this.canMove;
}
/**
**返回值:int
**方法:获得card的内容值
*/
public int getCardValue(){
return value;
}
/**
**返回值:int
**方法:获得card的类型
*/
public int getCardType(){
return type;
}
}
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
public class Spider extends JFrame{
//整型变量,表示难度等级为:简单
public static final int EASY = 1;
//整型变量,表示难度等级为:普通
public static final int NATURAL = 2;
//整型变量,表示难度等级为:难
public static final int HARD = 3;
//设定初始难度等级为简单
private int grade = Spider.EASY;
private Container pane = null;
//生成纸牌数组
private PKCard cards[] = new PKCard[104];
private JLabel clickLabel = null;
private int c = 0;
private int n = 0;
private int a = 0;
private int finish = 0;
Hashtable table = null;
private JLabel groundLabel[] = null;
public static void main(String[] args){
Spider spider = new Spider();
spider.setVisible(true);
}
/**
**构造函数
*/
public Spider(){
setTitle("蜘蛛牌");
setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);
//设置框架的大小
setSize(1024, 742);
//生成SpiderMenuBar对象,并放置在框架之上
setJMenuBar(new SpiderMenuBar(this));
pane = this.getContentPane();
//设置背景颜色
pane.setBackground(new Color(0, 112, 26));
//将布局管理器设置成为null
pane.setLayout(null);
clickLabel = new JLabel();
clickLabel.setBounds(883, 606, 121, 96);
pane.add(clickLabel);
clickLabel.addMouseListener(new MouseAdapter(){
public void mouseReleased(MouseEvent me){
if (c < 60){
Spider.this.deal();
}
}
});
this.initCards();
this.randomCards();
this.setCardsLocation();
groundLabel = new JLabel[10];