四人斗地主java程序
JAVA代码之斗地主发牌

JAVA代码之⽃地主发牌理解很好理解,关键是思路按照⽃地主的规则,完成洗牌发牌的动作: 具体规则:1. 组装54张扑克牌 2. 将54张牌顺序打乱3. 三个玩家参与游戏,三⼈交替摸牌,每⼈17张牌,最后三张留作底牌。
4. 查看三⼈各⾃⼿中的牌(按照牌的⼤⼩排序)、底牌⼿中扑克牌从⼤到⼩的摆放顺序:⼤王,⼩王,2,A,K,Q,J,10,9,8,7,6,5,4,3package com.oracle.demo01;import java.util.ArrayList;import java.util.Collections;import java.util.HashMap;import java.util.Map;public class Doudizhu {public static void main(String[] args) {//1.创建扑克牌MapMap<Integer,String> pooker=new HashMap<Integer,String>();//创建所有key所在的容器ArrayList<Integer> pookerNum=new ArrayList<Integer>();//创建花⾊数组String[] color={"♠","♣","♥","♦"};//创建牌号数组String[] number={"2","A","K","Q","J","10","9","8","7","6","5","4","3"};//造牌并存进map集合int index=2;for(String n:number){for(String c:color){//向map中存数据pooker.put(index,c+n);//向所有key所在的容器存数据pookerNum.add(index);index++;}}//存⼤⼩王pooker.put(0, "⼤王");pookerNum.add(0);pooker.put(1, "⼩王");pookerNum.add(1);//洗牌Collections.shuffle(pookerNum);//System.out.println(pookerNum);//发牌//创建四个容器ArrayList<Integer> bottom=new ArrayList<>();ArrayList<Integer> player1=new ArrayList<>();ArrayList<Integer> player2=new ArrayList<>();ArrayList<Integer> player3=new ArrayList<>();//开始发牌for(int i=0;i<pookerNum.size();i++){//将前三张给底牌if(i<3){bottom.add(pookerNum.get(i));}else if(i%3==0){player1.add(pookerNum.get(i));}else if(i%3==1){player2.add(pookerNum.get(i));}else if(i%3==2){player3.add(pookerNum.get(i));}}//排序(key升序牌从⼤到⼩)Collections.sort(bottom);Collections.sort(player1);Collections.sort(player2);Collections.sort(player3);//看牌(调⽤⽅法)look("刘德华",player1,pooker);look("张家辉",player2,pooker);look("周润发",player3,pooker);look("底牌",bottom,pooker);}//看牌的⽅法(传参为玩家姓名,玩家的牌即键,所有牌的键值对)public static void look( String name,ArrayList<Integer> player,Map<Integer,String> pooker){ //打印玩家姓名System.out.print(name+":");//遍历所有牌号for(int num:player){System.out.print(pooker.get(num)+" ");}System.out.println();}}。
java斗地主游戏项目源码

java⽃地主游戏项⽬源码部分代码如下Main.javapackage com;import java.awt.Color;import java.awt.Container;import java.awt.Point;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.util.ArrayList;import java.util.List;import java.util.Random;import javax.swing.ImageIcon;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JMenu;import javax.swing.JMenuBar;import javax.swing.JMenuItem;import javax.swing.JOptionPane;import javax.swing.JTextField;import javax.swing.SwingUtilities;public class Main extends JFrame implements ActionListener {public Container container = null;// 定义容器JMenuItem start, exit, about;// 定义菜单按钮JButton landlord[]=new JButton[2];//抢地主按钮JButton publishCard[]=new JButton[2];//出牌按钮int dizhuFlag;//地主标志int turn;JLabel dizhu; //地主图标List<Card> currentList[] =new ArrayList[3]; // 当前的出牌List<Card> playerList[] = new ArrayList[3]; // 定义3个玩家表List<Card> lordList;//地主牌Card card[] = new Card[56]; // 定义54张牌JTextField time[]=new JTextField[3]; //计时器Time t; //定时器(线程)boolean nextPlayer=false; //转换⾓⾊public Main(){Init();// 初始化SetMenu();// 创建菜单按钮(抢地主,发牌,计时器)this.setVisible(true);CardInit();//发牌getLord(); //发完牌开始抢地主time[1].setVisible(true);//线程安全性,把⾮主线程的UI控制放到⾥⾯SwingUtilities.invokeLater(new NewTimer(this,10));}// 抢地主public void getLord(){//System.out.println(CardType.c0.toString());for(int i=0;i<2;i++)landlord[i].setVisible(true);}//初始化牌// 发牌洗牌public void CardInit() {int count = 1;//初始化牌for (int i = 1; i <= 5; i++) {for (int j = 1; j <= 13; j++) {if ((i == 5) && (j > 2))break;else {card[count] = new Card(this, i + "-" + j, false);card[count].setLocation(350, 50);container.add(card[count]);count++;}}}//打乱顺序for(int i=0;i<100;i++){Random random=new Random();int a=random.nextInt(54)+1;int b=random.nextInt(54)+1;Card k=card[a];card[a]=card[b];card[b]=k;}//开始发牌for(int i=0;i<3;i++)playerList[i]=new ArrayList<Card>(); //玩家牌lordList=new ArrayList<Card>();//地主牌三张int t=0;for(int i=1;i<=54;i++){if(i>=52)//地主牌{Common.move(card[i], card[i].getLocation(),new Point(300+(i-52)*80,10)); lordList.add(card[i]);continue;}switch ((t++)%3) {case0://左边玩家Common.move(card[i], card[i].getLocation(),new Point(50,60+i*5));playerList[0].add(card[i]);break;case1://我Common.move(card[i], card[i].getLocation(),new Point(180+i*7,450));playerList[1].add(card[i]);card[i].turnFront(); //显⽰正⾯break;case2://右边玩家Common.move(card[i], card[i].getLocation(),new Point(700,60+i*5));playerList[2].add(card[i]);break;}//card[i].turnFront(); //显⽰正⾯container.setComponentZOrder(card[i], 0);}//发完牌排序,从⼤到⼩for(int i=0;i<3;i++){Common.order(playerList[i]);Common.rePosition(this,playerList[i],i);//重新定位}dizhu=new JLabel(new ImageIcon("images/dizhu.gif"));dizhu.setVisible(false);dizhu.setSize(40, 40);container.add(dizhu);}// 初始化窗体public void Init() {this.setTitle("java单机⽃地主");this.setSize(830, 620);setResizable(false);setLocationRelativeTo(getOwner()); // 屏幕居中container = this.getContentPane();container.setLayout(null);this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);container.setBackground(new Color(0, 112, 26)); // 背景为绿⾊}// 创建菜单功能按钮public void SetMenu() {JMenuBar jMenuBar = new JMenuBar();JMenu game = new JMenu("游戏");JMenu help = new JMenu("帮助");start = new JMenuItem("新游戏");exit = new JMenuItem("退出");about = new JMenuItem("关于");start.addActionListener(this);exit.addActionListener(this);about.addActionListener(this);game.add(start);game.add(exit);help.add(about);jMenuBar.add(game);jMenuBar.add(help);this.setJMenuBar(jMenuBar);landlord[0]=new JButton("抢地主");landlord[1]=new JButton("不抢");publishCard[0]= new JButton("出牌");publishCard[1]= new JButton("不要");for(int i=0;i<2;i++){publishCard[i].setBounds(320+i*100, 400, 60, 20);landlord[i].setBounds(320+i*100, 400,75,20);container.add(landlord[i]);landlord[i].addActionListener(this);landlord[i].setVisible(false);container.add(publishCard[i]);publishCard[i].setVisible(false);publishCard[i].addActionListener(this);}for(int i=0;i<3;i++){time[i]=new JTextField("倒计时:");time[i].setVisible(false);container.add(time[i]);}time[0].setBounds(140, 230, 60, 20);time[1].setBounds(374, 360, 60, 20);time[2].setBounds(620, 230, 60, 20);for(int i=0;i<3;i++){currentList[i]=new ArrayList<Card>();}}@Overridepublic void actionPerformed(ActionEvent e) {// TODO Auto-generated method stubif (e.getSource() == exit) {this.dispose();}if (e.getSource() == about) {JOptionPane.showMessageDialog(this, "哈哈");}if (e.getSource() == start) {// this.restart();}if(e.getSource()==landlord[0]){time[1].setText("抢地主");t.isRun=false; //时钟终结}if(e.getSource()==landlord[1]){time[1].setText("不抢");t.isRun=false; //时钟终结}//如果是不要if(e.getSource()==publishCard[1]){this.nextPlayer=true;currentList[1].clear();time[1].setText("不要");}//如果是出牌按钮if(e.getSource()==publishCard[0]){List<Card> c=new ArrayList<Card>();//点选出牌for(int i=0;i<playerList[1].size();i++){Card card=playerList[1].get(i);if(card.clicked){c.add(card);}}int flag=0;//如果我主动出牌if(time[0].getText().equals("不要")&&time[2].getText().equals("不要")) {if(Common.jugdeType(c)!=CardType.c0)flag=1;//表⽰可以出牌}//如果我跟牌else{flag=Common.checkCards(c,currentList);}//判断是否符合出牌if(flag==1){currentList[1]=c;playerList[1].removeAll(currentList[1]);//移除⾛的牌 //定位出牌Point point=new Point();point.x=(770/2)-(currentList[1].size()+1)*15/2;;point.y=300;for(int i=0,len=currentList[1].size();i<len;i++){Card card=currentList[1].get(i);Common.move(card, card.getLocation(), point); point.x+=15;}//抽完牌后重新整理牌Common.rePosition(this, playerList[1], 1);time[1].setVisible(false);this.nextPlayer=true;}}}public static void main(String args[]) {new Main();}}class NewTimer implements Runnable{Main main;int i;public NewTimer(Main m,int i){this.main=m;this.i=i;}@Overridepublic void run() {// TODO Auto-generated method stubmain.t=new Time(main,10);//从10开始倒计时main.t.start();}}效果图<ignore_js_op><ignore_js_op><ignore_js_op><ignore_js_op>详细说明:。
java实现斗地主发牌功能

java实现⽃地主发牌功能本⽂实例为⼤家分享了java实现⽃地主发牌的具体代码,供⼤家参考,具体内容如下参考⽃地主的游戏规则,完成⼀个发牌的功能(54张牌,考虑点数,花⾊;三名玩家,其中地主⽐其他玩家多3张牌)代码如下:牌类import java.util.Objects;/*** 3-10 J Q K A 2 King Queen 牌类** @author Administrator**/public class Card {/** 牌⾯值 */private String name;/** 花⾊ */private String flower;/** ⼤⼩点数 */private int num;public Card() {super();}public Card(String name, String flower, int num) {super(); = name;this.flower = flower;this.num = num;}public String getName() {return name;}public void setName(String name) { = name;}public String getFlower() {return flower;}public void setFlower(String flower) {this.flower = flower;}public int getNum() {return num;}public void setNum(int num) {this.num = num;}@Overridepublic String toString() {if(Objects.nonNull(flower)) {return name + "-" + flower;}return name;}}玩家类public class Player {/**玩家ID*/private int id;/**玩家姓名*/private String name;/**是否是地主*/private boolean boss;/**牌集合*/private ArrayList<Card> cards = new ArrayList<Card>();public Player(int id, String name, boolean boss, ArrayList<Card> cards) {super();this.id = id; = name;this.boss = boss;this.cards = cards;}public Player() {super();}public int getId() {return id;}public void setId(int id) {this.id = id;}public String getName() {return name;}public void setName(String name) { = name;}public boolean isBoss() {return boss;}public void setBoss(boolean boss) {this.boss = boss;}public ArrayList<Card> getCards() {return cards;}public void setCards(ArrayList<Card> cards) {this.cards = cards;}@Overridepublic String toString() {return name +(boss? "(地主):":"(农名):")+ cards;}}管理类public class GameManage {private static Random randomGen = new Random();/** 声明所有牌的集合 */private static ArrayList<Card> all = new ArrayList<Card>();/** ⽤于⽣成牌的牌⾯值 */private static String[] names = { "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A", "2", "⼩王","⼤王" }; /** ⽤于⽣成牌的花⾊ */private static String[] flowers = { "红桃", "⽅块", "梅花", "⿊桃" };private ArrayList<Player> players = new ArrayList<Player>();static {int i = 0;for (; i < names.length - 2; i++) {for (int j = 0; j < flowers.length; j++) {Card c = new Card(names[i], flowers[j], i);all.add(c);}}// 将⼤⼩王加⼊all.add(new Card(names[names.length - 2], null, i++)); all.add(new Card(names[names.length - 1], null, i++)); }/*** 加⼊玩家*/private void addPlayer() {Scanner sc = new Scanner(System.in);System.out.println("请输⼊玩家1名称:");String name1 = sc.nextLine();System.out.println("请输⼊玩家2名称:");String name2 = sc.nextLine();System.out.println("请输⼊玩家3名称:");String name3 = sc.nextLine();Player p1 = new Player();p1.setId(1);p1.setName(name1);Player p2 = new Player();p1.setId(2);p2.setName(name2);Player p3 = new Player();p1.setId(3);p3.setName(name3);// 将三名玩家加⼊集合players.add(p1);players.add(p2);players.add(p3);}/*** 随机地主*/private void randomBoss() {// 添加玩家addPlayer();// 随机地主索引int i = randomGen.nextInt(players.size());// 设置指定位置的玩家为地主players.get(i).setBoss(true);}public ArrayList<Player> sendCard() {randomBoss();// 对每⼀名玩家遍历for (Player p : players) {// 先为每⼀位玩家随机发17张牌for (int i = 0; i < 17; i++) {// 随机⼀张牌的索引int cardIndex = randomGen.nextInt(all.size());// 获取随机索引位置的牌Card card = all.get(cardIndex);// 将随机的牌加⼊当前遍历玩家的集合p.getCards().add(card);// 从源集合中移除这张牌all.remove(card);}}// 最后三张牌给地主for (Player p : players) {if (p.isBoss()) {// 将all集合中的所有元素加⼊地主的集合p.getCards().addAll(all);}}return players;}}以上就是本⽂的全部内容,希望对⼤家的学习有所帮助,也希望⼤家多多⽀持。
Java集合案例之斗地主游戏

Java集合案例之⽃地主游戏本⽂实例为⼤家分享了Java集合案例之⽃地主游戏的具体代码,供⼤家参考,具体内容如下题⽬要求:通过⾃制54张扑克牌,发给3⼈,留下3张底牌,分别显⽰不同⼈的⼿牌与底牌达到⽃地主的游戏需求算法思想:1、4种花⾊,每种13张牌,使⽤for嵌套循环,产⽣52张牌再加⼊⼤⼩王创建牌与花⾊:String[] hs = {"♠", "♥", "♣", "♦"};String[] number = {"3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A", "2"};2、为了⽅便表⽰与操作每⼀张牌,可以⽤1--54的数字代替54种牌,通过此思路:可以使⽤HashMap类,使得牌与数字⼀⼀对应。
Map<Integer, String> pokers = new HashMap<>(); //双列表实现数字与牌相对应List<Integer> list = new ArrayList<>(); //单表存数字int n = 0;//⽤来计算3、考虑当分到牌后使其排列⽅便,可在设置数字对应时,进⾏特殊操作:使得花⾊作为内循环,数字作为内循环这样:在显⽰牌⾯时,更符合⽤户需求for (String s : number) {for (String h : hs) {String poker = h + s; //组合得到52张牌num++; //计数pokers.put(num, poker); //双列表,实现⼤⼩与数组对应list.add(num); //单列表,⽅便操作}}注:通过增强for循环来进⾏遍历num++;pokers.put(num, "⼩王"); //添加⼩王list.add(num);num++;pokers.put(num, "⼤王"); //添加⼤王list.add(num);4、调⽤Collections.shuffle(list)⽅法,使单列表打乱顺序,使⽤ int i 进⾏遍历,留下最后三张作为底牌,再将剩余的51张牌分给三⼈。
斗地主洗牌课课程设计JAVA

斗地主洗牌课课程设计JAVA一、教学目标本课程旨在通过斗地主洗牌程序的设计与实现,让学生掌握JAVA编程的基本语法、流程控制、数组和面向对象编程等知识,培养学生解决实际问题的能力,提高学生的编程兴趣和信息素养。
具体目标如下:1.理解JAVA编程语言的基本语法。
2.掌握JAVA中的流程控制语句,包括条件语句、循环语句等。
3.熟悉JAVA数组的使用方法。
4.理解面向对象编程的基本概念,包括类、对象、封装、继承等。
5.能够运用JAVA编程语言编写简单的程序。
6.能够运用面向对象编程思想设计和实现程序。
7.能够分析问题,编写解决问题的JAVA程序。
情感态度价值观目标:1.培养学生对编程的兴趣,提高信息素养。
2.培养学生团队合作、自主学习的能力。
3.培养学生面对问题,解决问题的决心和毅力。
二、教学内容本课程的教学内容主要包括JAVA编程语言的基本语法、流程控制、数组和面向对象编程等。
1.JAVA基本语法:JAVA的数据类型、变量、运算符、方法等。
2.流程控制:条件语句、循环语句等。
3.数组:一维数组、多维数组的使用和操作。
4.面向对象编程:类、对象、封装、继承等。
三、教学方法本课程采用讲授法、案例分析法、实验法等教学方法,以激发学生的学习兴趣和主动性。
1.讲授法:用于讲解JAVA的基本语法、流程控制、数组和面向对象编程等理论知识。
2.案例分析法:通过分析实际案例,让学生理解和掌握JAVA编程的方法。
3.实验法:通过编写和运行JAVA程序,让学生实践和巩固所学知识。
四、教学资源本课程的教学资源包括教材、多媒体资料和实验设备等。
1.教材:选用《JAVA编程思想》等权威教材,为学生提供系统的学习资料。
2.多媒体资料:制作课件、演示视频等,丰富教学手段,提高学生的学习兴趣。
3.实验设备:为学生提供电脑、网络等实验环境,方便学生进行编程实践。
五、教学评估本课程的教学评估主要包括平时表现、作业和考试三个部分,以全面、客观、公正地评估学生的学习成果。
java课程设计斗地主

java课程设计斗地主一、教学目标本章节的教学目标旨在让学生掌握Java编程基础,能够运用Java编写简单的斗地主游戏。
具体目标如下:1.理解Java编程语言的基本语法和结构。
2.掌握面向对象编程的思想,了解类、对象、继承、多态等概念。
3.学习Java集合框架,了解List、Set、Map等接口及其实现类。
4.熟悉Java异常处理机制。
5.能够使用Java开发工具,如Eclipse、IntelliJ IDEA等。
6.能够编写简单的Java程序,实现输入输出、数据计算等功能。
7.能够运用Java编写斗地主游戏的界面和逻辑。
情感态度价值观目标:1.培养学生的编程兴趣,提高学生主动学习的积极性。
2.培养学生团队协作的能力,学会与他人共同解决问题。
3.培养学生勇于创新的精神,敢于挑战自己。
二、教学内容本章节的教学内容主要包括以下几个部分:1.Java编程基础:介绍Java语言的基本语法、数据类型、运算符、控制结构等。
2.面向对象编程:讲解类、对象、继承、多态等概念,并通过实例让学生理解并掌握这些概念。
3.Java集合框架:学习List、Set、Map等接口及其实现类,了解常用的数据结构及其应用场景。
4.异常处理:介绍Java异常处理机制,让学生学会处理程序中可能出现的错误和异常。
5.斗地主游戏开发:引导学生运用所学知识,编写斗地主游戏的界面和逻辑。
三、教学方法本章节的教学方法采用讲授法、案例分析法和实验法相结合的方式,具体如下:1.讲授法:教师讲解Java编程基础、面向对象编程、集合框架、异常处理等内容,引导学生理解并掌握相关概念。
2.案例分析法:通过分析具体的斗地主游戏案例,让学生将所学知识运用到实际项目中,提高学生的编程能力。
3.实验法:安排实验室实践环节,让学生动手编写斗地主游戏,培养学生的实际操作能力。
四、教学资源本章节的教学资源包括以下几部分:1.教材:《Java编程基础》等相关教材,为学生提供理论知识的学习依据。
使用Java实现简单的斗地主案例

public static void main(String[] args) {
//定义扑克牌的花色以及数字的数组 String[] flower = {"♥ ","♠ ","♣ ","♦ "}; String[] numbers = {"A","2",,"6","7","8","9","10","J","Q","K"};
} }
//添加大小王到牌组集合中 poker.add("大王"); poker.add("小王");
//打印输出所有扑克牌测试 System.out.println(poker);
//定义三个玩家和地主牌的集合 List player1 = new ArrayList(); List player2 = new ArrayList(); List player3 = new ArrayList(); List dizhupai = new ArrayList();
//创建牌组集合 List poker = new ArrayList();
//组合扑克牌样式 //拿出每一个花色,然后跟每一个数字进行结合,储存在牌组中 for (int i = 0; i < flower.length; i++) {
for (int j = 0; j < numbers.length; j++) { poker.add(flower[i].concat(numbers[j]));
斗地主 JAVA课程设计

包括总体设计、详细设计、编码实现、测试。设计要求如下: ①游戏由模块组成:游戏区模块,游戏控制模块,级别设置模块和帮助模块。 ②游戏区模块,为玩家提供主体游戏功能,能够处理玩家的各种游戏操作,显示得
指导教师(签名):
20 年 月 日
目录
1 需求与总体设计......................................................................................................................1 1.1 需求分析..............................................................................................................................1 1.2 总体设计..............................................................................................................................1 1.3 功能图..................................................................................................................................1 1.4 类图......................................................................................................................................2 2 详细设计..................................................................................................................................3 2.1 主类 Main.............................................................................................................................3 2.2 类 Card.................................................................................................................................3 2.3 类 CardType.........................................................................................................................4 2.4 类 Common.............................................................................................................................4 2.5 类 Model...............................................................................................................................5 2.6 类 Time.................................................................................................................................5 3 编码实现..................................................................................................................................6 3.1 JAVA 编码实现....................................................................................................................6 4 系统测试................................................................................................................................44 4.1 测试结果............................................................................................................................44 4.2 排错处理............................................................................................................................46 总 结............................................................................................................................................................47
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
package poker;/*** <p>Title: 斗地主</p>* <p>Description: </p>* <p>Copyright: Copyright (c) 2004</p>* <p>Company: </p>* author 艳生* version 1.0*/import java.awt.*;import javax.swing.*;import java.awt.event.*;import java.util.*;public class CallPokerDialog extends JDialog{JButton btnOne = new JButton();JButton btnTwo = new JButton();JButton btnThree = new JButton();JButton btnFour = new JButton();int score = PokerKernal.score;public CallPokerDialog() {try {jbInit();}catch(Exception e) {e.printStackTrace();}}private void jbInit() throws Exception {this.setSize(new Dimension(330, 80));//居中显示Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();this.setLocation((screenSize.width - 330)/2,(screenSize.height - 80)/2);this.setModal(true);this.setResizable(false);this.setTitle("请叫牌");if(score==1){btnOne.setBackground(Color.pink);}else if(score==2){btnOne.setBackground(Color.pink);btnTwo.setBackground(Color.pink);}btnOne.setBounds(new Rectangle(11, 16, 67, 25));btnOne.setText("1分");btnOne.addActionListener(newCallPokerDialog_btnOne_actionAdapter(this));this.getContentPane().setLayout(null);btnTwo.setBounds(new Rectangle(82, 17, 73, 25));btnTwo.setText("2分");btnTwo.addActionListener(newCallPokerDialog_btnTwo_actionAdapter(this));btnThree.setBounds(new Rectangle(161, 17, 73, 25));btnThree.setText("3分");btnThree.addActionListener(newCallPokerDialog_btnThree_actionAdapter(this));btnFour.setBounds(new Rectangle(240, 16, 73, 25));btnFour.setSelected(false);btnFour.setText("不要");btnFour.addActionListener(newCallPokerDialog_btnFour_actionAdapter(this));this.getContentPane().add(btnOne, null);this.getContentPane().add(btnTwo, null);this.getContentPane().add(btnThree, null);this.getContentPane().add(btnFour, null);}void btnOne_actionPerformed(ActionEvent e) {if(score<1){PokerKernal.score = 1;PokerKernal.two.call = 1;this.dispose();}}void btnTwo_actionPerformed(ActionEvent e) {if(score<2){PokerKernal.two.call = 2;PokerKernal.score = 2;this.dispose();}}void btnThree_actionPerformed(ActionEvent e) {if(score<3){PokerKernal.two.call = 3;PokerKernal.score = 3;this.dispose();}}void btnFour_actionPerformed(ActionEvent e) {this.dispose();}}class CallPokerDialog_btnOne_actionAdapter implements java.awt.event.ActionListener {CallPokerDialog adaptee;CallPokerDialog_btnOne_actionAdapter(CallPokerDialog adaptee) { this.adaptee = adaptee;}public void actionPerformed(ActionEvent e) {adaptee.btnOne_actionPerformed(e);}}class CallPokerDialog_btnTwo_actionAdapter implements java.awt.event.ActionListener {CallPokerDialog adaptee;CallPokerDialog_btnTwo_actionAdapter(CallPokerDialog adaptee) { this.adaptee = adaptee;}public void actionPerformed(ActionEvent e) {adaptee.btnTwo_actionPerformed(e);}}class CallPokerDialog_btnThree_actionAdapter implements java.awt.event.ActionListener {CallPokerDialog adaptee;CallPokerDialog_btnThree_actionAdapter(CallPokerDialog adaptee) {this.adaptee = adaptee;}public void actionPerformed(ActionEvent e) {adaptee.btnThree_actionPerformed(e);}}class CallPokerDialog_btnFour_actionAdapter implements java.awt.event.ActionListener {CallPokerDialog adaptee;CallPokerDialog_btnFour_actionAdapter(CallPokerDialog adaptee) { this.adaptee = adaptee;}public void actionPerformed(ActionEvent e) {adaptee.btnFour_actionPerformed(e);}}package poker;/*** <p>Title: 斗地主</p>* <p>Description: 牌类</p>* <p>Copyright: Copyright (c) 2004</p>* <p>Company: </p>* author 艳生* version 1.0*/import java.awt.*;import java.awt.image.*;public class Card {//牌名称private String name;//牌点数private int dot;//牌图片private Image img;public Card() {name = "";dot = 0;img = null;}public Card(String name, int dot, Image img) { = name;this.dot = dot;this.img = img;}public int getDot() {return dot;}public Image getImg() {return img;}public String getName() {return name;}public void setName(String name) { = name;}public void setImg(Image img) { this.img = img;}public void setDot(int dot) { this.dot = dot;}}package poker;/*** <p>Title: 斗地主</p>* <p>Description: 牌操作</p>* <p>Copyright: Copyright (c) 2004</p> * <p>Company: </p>* author 艳生* version 1.0*/import java.awt.*;import java.awt.Graphics2D;import java.util.*;import java.awt.event.*;import javax.swing.*;import .URL;import .URLClassLoader;public class CardOperation {//所有牌对象集public static Vector cards = new Vector();public CardOperation() {}/**加载扑克图片*/public static void loadCards(Component cmp){//s--黑桃(spade) h--红桃(hearts) c--梅花(club) d--方块(diamond)String name[] = {"s","h","c","d"};String dot[] = {"3","4","5","6","7","8","9","10","j","q","k","a","2"};//权值int power[] = {3,4,5,6,7,8,9,10,11,12,13,14,15};URLClassLoader urlLoader = (URLClassLoader)cmp.getClass().getClassLoader();URL fileLoc = null;Card card = null;//先读52牌for(int i=0; i<4;i++){for(int j=0;j<13;j++){fileLoc = urlLoader.findResource("cards/"+name[i]+dot[j]+".jpg");card = new Card(name[i]+dot[j], power[j], cmp.getToolkit().createImage(fileLoc));cards.addElement(card);}}//再读大小王fileLoc = urlLoader.findResource("cards/b.jpg");card = new Card("b",200,cmp.getToolkit().createImage(fileLoc));cards.addElement(card);fileLoc = urlLoader.findResource("cards/s.jpg");card = new Card("s",100,cmp.getToolkit().createImage(fileLoc));cards.addElement(card);//牌背景fileLoc = urlLoader.findResource("cards/bg.jpg");card = new Card("bg",0,cmp.getToolkit().createImage(fileLoc));cards.addElement(card);//初始化Card c = new Card();for(int i=0;i<54;i++){PokerKernal.postCards.addElement(c);}for(int i=0;i<20;i++){PokerKernal.oneCards.addElement(c);PokerKernal.twoCards.addElement(c);PokerKernal.threeCards.addElement(c);PokerKernal.selectCards.addElement(c);}PokerKernal.master = "one";}package poker;import javax.swing.*;import java.awt.*;import java.awt.event.*;/*** <p>Title: 斗地主</p>* <p>Description: </p>* <p>Copyright: Copyright (c) 2004</p>* <p>Company: </p>* author 艳生* version 1.0*/public class HelpDialog extends JDialog {JTextArea txtHelp = new JTextArea();JButton btnOK = new JButton();public HelpDialog() throws HeadlessException {try {jbInit();}catch(Exception e) {e.printStackTrace();}}private void jbInit() throws Exception {//居中显示Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();this.setLocation((screenSize.width - 450)/2,(screenSize.height - 350)/2);this.setSize(new Dimension(450, 350));this.setModal(true);this.setResizable(false);this.setTitle("游戏规则");txtHelp.setBackground(Color.black);txtHelp.setForeground(Color.green);txtHelp.setText("该游戏由三人玩一副牌,地主为一方,其余两家为一方,\n"+"双方对战,先出完的一方为胜。