- 浏览: 17915 次
- 性别:
- 来自: 苏州
文章分类
最新评论
-
wpf523:
实践才能出真知!
如何安装apache ivy -
august_000:
ivy管理记录、跟踪、解析和报告,可以具体点么?我觉得MVN就 ...
如何安装apache ivy -
flyfan:
个人对Maven项目结构不是很满意,其它都没什么
如何安装apache ivy -
evanz:
appfuse 1.x 的版本早就通过lib.properti ...
如何安装apache ivy -
xds2000:
试回答:请问和Maven2有什么不一样的?答:当你不想使用ma ...
如何安装apache ivy
简单的纸牌游戏,需求依靠com.borland.jbcl.layout.*,可以从jbuilder下找到 :
package sample;
import java.awt.*;
import javax.swing.*;
import com.borland.jbcl.layout.*;
import java.awt.event.*;
import java.awt.event.ActionListener;
import java.lang.Thread;
public class MainFrame extends JFrame implements ActionListener/* implements ActionLisener*/
{
XYLayout xYLayout1 = new XYLayout();
JPanel jPanel1 = new JPanel();
XYLayout xYLayout2 = new XYLayout();
/*JTextField jTextField1 = new JTextField();
JTextField jTextField2 = new JTextField();
JTextField jTextField3 = new JTextField();
JTextField jTextField4 = new JTextField();
JTextField jTextField5 = new JTextField();
*/
JTextField jTextField6 = new JTextField();
JTextField jTextField7 = new JTextField();
/* JButton jButton1 = new Poker();
JButton jButton2 = new Poker();
JButton jButton3 = new Poker();
JButton jButton4 = new Poker();
JButton jButton5 = new Poker();*/
JTextField[] jTextField;
JButton jButton6 = new JButton();
Picture pic[][];
Poker [] jButton;
ImageIcon back = new ImageIcon("./src/cards/b.gif");
static int money=100;
static boolean start=false;
boolean bool_1,bool_2,bool_3,bool_4,bool_5;
int a,b;
static int row=4;
static int column=13;
String addr ;
boolean key =false;
JLabel jLabel1 = new JLabel();
public MainFrame() {
try {
UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
SwingUtilities.updateComponentTreeUI(this);
}
catch (UnsupportedLookAndFeelException ex) {
}
catch (IllegalAccessException ex) {
}
catch (InstantiationException ex) {
}
catch (ClassNotFoundException ex) {
}
pic = new Picture[row][column];
createIcon();
/* for (int i = 0; i < 4; i++)
for (int j = 0; j < 13; j++) {
addr = "./src/cards/pic_" + i + "_" + j + ".gif";
pic[i][j] = new Picture();
pic[i][j].zx = i;
pic[i][j].zy = j;
pic[i][j].select = false;
}*/
jButton = new Poker[5];
for(int i=0;i<5;i++)
{
jButton[i] = new Poker();
jButton[i].n =i;
//jButton[i].stat =true;
jButton[i].addActionListener(this);
}
jTextField = new JTextField[5];
for(int i=0;i<5;i++)
{
jTextField[i] = new JTextField();
}
try {
jbInit();
this.setSize(800,400);
}
catch(Exception e) {
e.printStackTrace();
}
}
private void jbInit() throws Exception {
xYLayout1.setWidth(790);
xYLayout1.setHeight(358);
jTextField[4].setRequestFocusEnabled(true);
jTextField[4].setEditable(false);
jTextField[4].setText("");
jTextField[3].setVerifyInputWhenFocusTarget(true);
jTextField[3].setEditable(false);
jTextField[3].setText("");
jTextField[3].addActionListener(new MainFrame_jTextField3_actionAdapter(this));
jTextField[1].setEditable(false);
jTextField[1].setText("");
jTextField[1].addActionListener(new MainFrame_jTextField1_actionAdapter(this));
jPanel1.setLayout(xYLayout2);
this.getContentPane().setLayout(xYLayout1);
jTextField6.setVerifyInputWhenFocusTarget(true);
jTextField6.setEditable(false);
jTextField6.setText("你有现金 "+money+"元");
jTextField6.addActionListener(new MainFrame_jTextField6_actionAdapter(this));
jTextField7.setEditable(false);
jTextField7.setText("每次 5元");
jTextField7.addActionListener(new MainFrame_jTextField7_actionAdapter(this));
/*
jButton1.setText("jButton1");
jButton2.setText("jButton1");
jButton3.setText("jButton1");
jButton4.setText("jButton1");
jButton5.setText("jButton1");
*/
jPanel1.setBorder(BorderFactory.createTitledBorder("you are playing"));
jButton6.setText("发牌");
jButton6.addActionListener(new MainFrame_jButton6_actionAdapter(this));
jTextField[2].setEditable(false);
jTextField[2].setText("");
jTextField[0].setEditable(false);
jTextField[0].setText("");
jButton[0].setIcon(back);
jButton[1].setIcon(back);
jButton[2].setIcon(back);
jButton[3].setIcon(back);
jButton[4].setIcon(back);
jLabel1.setAlignmentY((float) 0.8);
jLabel1.setMaximumSize(new Dimension(18, 16));
jLabel1.setOpaque(false);
jLabel1.setPreferredSize(new Dimension(18, 16));
jLabel1.setIconTextGap(4);
jLabel1.setText("");
jLabel1.setVerticalAlignment(javax.swing.SwingConstants.CENTER);
jLabel1.setVerticalTextPosition(javax.swing.SwingConstants.CENTER);
jPanel1.add(jButton[0], new XYConstraints(36, 87, 73, 97));
jPanel1.add(jButton[1], new XYConstraints(145, 87, 73, 97));
jPanel1.add(jButton[2], new XYConstraints(258, 87, 73, 97));
jPanel1.add(jButton[3], new XYConstraints(364, 87, 73, 97));
jPanel1.add(jButton[4], new XYConstraints(462, 87, 73, 97));
jPanel1.add(jTextField6, new XYConstraints(565, 46, 128, 23));
jPanel1.add(jTextField7, new XYConstraints(566, 120, 128, 23));
this.getContentPane().add(jLabel1, new XYConstraints(406, 294, 140, 40));
jPanel1.add(jTextField[0], new XYConstraints(45, 31, 55, 23));
jPanel1.add(jTextField[1], new XYConstraints(154, 31, 55, 23));
jPanel1.add(jTextField[2], new XYConstraints(266, 31, 55, 23));
jPanel1.add(jTextField[3], new XYConstraints(369, 31, 55, 23));
jPanel1.add(jTextField[4], new XYConstraints(470, 31, 55, 23));
this.getContentPane().add(jButton6, new XYConstraints(31, 285, 93, 31));
this.getContentPane().add(jPanel1, new XYConstraints(32, 22, 725, 256));
}
void jTextField3_actionPerformed(ActionEvent e) {
}
void jTextField1_actionPerformed(ActionEvent e) {
}
void jButton6_actionPerformed(ActionEvent e) {
System.out.println("hello----------------------");
if(start ==false)
{
newPoker();
// createIcon();
money -=5;
jTextField6.setText("你有现金 "+money+"元");
System.out.print("******************");
for (int i = 0; i < 5; i++) {
jTextField[i].setText(null);
}
jLabel1.setText(null);
start = true;
}else
{
System.out.println("execute---------------------------");
//pic_back();
execPoker();
shuanfa();
start=false;
}
}
public void shuanfa()
{
int a[] =new int[5];
int b[] =new int [5];
int tmp_a;
int tmp_b;
for (int i = 0; i < 5; i++) {
a[i] = jButton[i].x;
b[i] = jButton[i].y;
}
for(int i=1;i<5;i++)
for(int j=0;j<4;j++)
{
if(b[j]>b[j+1])
{
tmp_b=b[j];b[j]=b[j+1];b[j+1]=tmp_b;
tmp_a=a[j];a[j]=a[j+1];a[j+1]=tmp_a;
}
}
if((b[0]==b[1])&&(b[1]==b[2])&&(b[2]==b[3])||(b[1]==b[2])&&(b[2]==b[3])&&(b[3]==b[4]))
{
money +=150;
jTextField6.setText("你有现金 "+money+"元");
System.out.println("you win "+150);
jLabel1.setText("you win "+150);
}
else if(((b[0]==b[1])&&(b[1]==b[2])&&(b[3]==b[4]))||((b[0]==b[1])&&(b[2]==b[3])&&(b[3]==b[4])))
{
money += 60;
jTextField6.setText("你有现金 " + money + "元");
System.out.println("you win " + 60);
jLabel1.setText("you win "+60);
}
else if((((b[0]==b[1]-1)&&(b[0]==b[2]-2)&&(b[0]==b[3]-3)&&(b[0]==b[4]-4))
&&((a[0]==a[1])&&(a[1]==a[2])&&(a[2]==a[3])&&(a[3]==a[4])))||(
((b[1]==9)&&(b[2]==10)&&(b[3]==11)&&(b[4]==12))&&
(a[0]==a[1])&&(a[0]==a[2])&&(a[0]==a[3])&&(a[0]==a[4])&&(b[0]==0)
))
{
money += 200;
jTextField6.setText("你有现金 " + money + "元");
System.out.println("you win " + 200);
jLabel1.setText("you win "+200);
}
else if((a[0]==a[1])&&(a[1]==a[2])&&(a[2]==a[3])&&(a[3]==a[4]))
{
money += 50;
jTextField6.setText("你有现金 " + money + "元");
System.out.println("you win " + 50);
jLabel1.setText("you win "+50);
}
else if(((b[0]==b[1]-1)&&(b[0]==b[2]-2)&&(b[0]==b[3]-3)&&(b[0]==b[4]-4))
||((b[1]==9)&&(b[2]==10)&&(b[3]==11)&&(b[4]==12)&&(b[0]==0)))
{
money += 40;
jTextField6.setText("你有现金 " + money + "元");
System.out.println("you win " + 40);
jLabel1.setText("you win "+40);
}
else if((b[0]==b[1])&&(b[1]==b[2])||(b[1]==b[2])&&(b[2]==b[3])
||(b[2]==b[3])&&(b[3]==b[4]))
{
money += 30;
jTextField6.setText("你有现金 " + money + "元");
System.out.println("you win " + 30);
jLabel1.setText("you win "+30);
}
else if ((b[0]==b[1])&&(b[2]==b[3])||(b[0]==b[1])&&(b[3]==b[4])||
(b[1]==b[2])&&(b[3]==b[4]))
{
money += 15;
jTextField6.setText("你有现金 " + money + "元");
System.out.println("you win " + 15);
jLabel1.setText("you win "+15);
}
else if (((b[0]==b[1])&&b[0]>9)||((b[1]==b[2])&&b[1]>9)||
((b[2]==b[3])&&b[2]>9)||((b[3]==b[4])&&b[3]>9)||
(b[0]==b[1])&&(b[0]==0))
{
money += 10;
jTextField6.setText("你有现金 " + money + "元");
System.out.println("you win " + 10);
jLabel1.setText("you win "+10);
}
else
{
System.out.println("you lose-----------------");
jLabel1.setText("you lose ");
}
/* for(int i=0;i<5;i++)
{
System.out.println("--------------a[i]------" + a[i]);
System.out.println("--------------b[i]------" + b[i]);
}*/
}
public void execPoker()
{
// pic_back();
for (int i = 0; i < 5; ) {
if(jButton[i].keep ==false)
{
int x = (int) (Math.random() * (4 - 1) + 0.5);
int y = (int) (Math.random() * (13 - 1) + 0.5);
if (pic[x][y].getselect()) {
continue;
}
else
{
// jButton[i].setIcon(null);
//jButton[i].setText("ddddd");
System.out.println("sleep--------");
/* try {
Thread.sleep(1000);
}
catch (InterruptedException ex) {
}*/
pic[x][y].setselect();
jButton[i].setIcon(pic[x][y]);
// jButton[i].setIcon(back);
jButton[i].x = x;
jButton[i].y = y;
i++;
}
}else
{
i++;
}
}
for(int i=0;i<5;i++)
{
jTextField[i].setText(null);
}
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 13; j++) {
pic[i][j].select = false;
}
}
for(int i=0;i<5;i++)
{
jButton[i].stat = true;
jButton[i].keep =false;
}
}
public void pic_back()
{
for (int i = 0; i < 5;i++ ) {
if (jButton[i].keep == false)
{
jButton[i].setIcon(back);
jButton[i].repaint();
System.out.println("@@@@@@@@ "+i);
}
}
}
void jTextField7_actionPerformed(ActionEvent e) {
}
public void actionPerformed(ActionEvent e)
{
Poker pok =(Poker)e.getSource();
int i =pok.x;
int j =pok.y;
int nn=pok.n;
System.out.println("#####################");
if(start == true)
{
if(jButton[nn].stat==true)
{
jTextField[nn].setText("持牌");
pic[i][j].select = true;
System.out.println("select on-------------------"+i);
System.out.println("select on-------------------"+j);
jButton[nn].keep =true;
System.out.println("true______________________");
jButton[nn].stat =false;
}
else
{
jTextField[nn].setText(null);
pic[i][j].select =false;
jButton[nn].stat=true;
System.out.println("select off-------------------"+i);
System.out.println("select off-------------------"+j);
System.out.println("false_______________________");
jButton[nn].keep=false;
}
}
}
public void createIcon(){
// pic = new Picture[row][column];
for (int i = 0; i < 4; i++)
for (int j = 0; j < 13; j++) {
addr = "./src/cards/pic_" + i + "_" + j + ".gif";
pic[i][j] = new Picture(addr);
pic[i][j].zx = i;
pic[i][j].zy = j;
// pic[i][j].select = false;
}
}
public void newPoker()
{
// zero();
for(int i=0;i<5;)
{
int x = (int) (Math.random() * (4 - 1) + 0.5);
int y = (int) (Math.random() * (13- 1) + 0.5);
if(pic[x][y].getselect())
continue;
pic[x][y].setselect();
jButton[i].setIcon(pic[x][y]);
jButton[i].x=x;
jButton[i].y=y;
i++;
}
/* for (int i = 0; i < 4; i++) {
for (int j = 0; j < 13; j++) {
pic[i][j].select =false ;
}
}*/
//start=true;
}
public void zero() {
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 13; j++) {
pic[i][j].setselect();
}
}
}
void jTextField6_actionPerformed(ActionEvent e) {
}
}
class MainFrame_jTextField3_actionAdapter implements java.awt.event.ActionListener {
MainFrame adaptee;
MainFrame_jTextField3_actionAdapter(MainFrame adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jTextField3_actionPerformed(e);
}
}
class MainFrame_jTextField1_actionAdapter implements java.awt.event.ActionListener {
MainFrame adaptee;
MainFrame_jTextField1_actionAdapter(MainFrame adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jTextField1_actionPerformed(e);
}
}
class MainFrame_jButton6_actionAdapter implements java.awt.event.ActionListener {
MainFrame adaptee;
MainFrame_jButton6_actionAdapter(MainFrame adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton6_actionPerformed(e);
}
}
class MainFrame_jTextField7_actionAdapter implements java.awt.event.ActionListener {
MainFrame adaptee;
MainFrame_jTextField7_actionAdapter(MainFrame adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jTextField7_actionPerformed(e);
}
}
class Poker extends JButton
{
int n;//
int x;
int y;
boolean stat=true;
boolean keep=false;
Poker(){
}
Poker(int x,int y){
this.x=x;
this.y=y;
}
}
class Picture extends ImageIcon
{
int zx;
int zy;
boolean select =false;
String a;
Picture(){
}
public Picture(String a){
super(a);
//this.a =a;
}
public boolean getselect(){
return this.select;
}
public void setselect(){
this.select=true;
}
}
class MainFrame_jTextField6_actionAdapter implements java.awt.event.ActionListener {
MainFrame adaptee;
MainFrame_jTextField6_actionAdapter(MainFrame adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jTextField6_actionPerformed(e);
}
}
package sample;
import java.awt.*;
import javax.swing.*;
import com.borland.jbcl.layout.*;
import java.awt.event.*;
import java.awt.event.ActionListener;
import java.lang.Thread;
public class MainFrame extends JFrame implements ActionListener/* implements ActionLisener*/
{
XYLayout xYLayout1 = new XYLayout();
JPanel jPanel1 = new JPanel();
XYLayout xYLayout2 = new XYLayout();
/*JTextField jTextField1 = new JTextField();
JTextField jTextField2 = new JTextField();
JTextField jTextField3 = new JTextField();
JTextField jTextField4 = new JTextField();
JTextField jTextField5 = new JTextField();
*/
JTextField jTextField6 = new JTextField();
JTextField jTextField7 = new JTextField();
/* JButton jButton1 = new Poker();
JButton jButton2 = new Poker();
JButton jButton3 = new Poker();
JButton jButton4 = new Poker();
JButton jButton5 = new Poker();*/
JTextField[] jTextField;
JButton jButton6 = new JButton();
Picture pic[][];
Poker [] jButton;
ImageIcon back = new ImageIcon("./src/cards/b.gif");
static int money=100;
static boolean start=false;
boolean bool_1,bool_2,bool_3,bool_4,bool_5;
int a,b;
static int row=4;
static int column=13;
String addr ;
boolean key =false;
JLabel jLabel1 = new JLabel();
public MainFrame() {
try {
UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
SwingUtilities.updateComponentTreeUI(this);
}
catch (UnsupportedLookAndFeelException ex) {
}
catch (IllegalAccessException ex) {
}
catch (InstantiationException ex) {
}
catch (ClassNotFoundException ex) {
}
pic = new Picture[row][column];
createIcon();
/* for (int i = 0; i < 4; i++)
for (int j = 0; j < 13; j++) {
addr = "./src/cards/pic_" + i + "_" + j + ".gif";
pic[i][j] = new Picture();
pic[i][j].zx = i;
pic[i][j].zy = j;
pic[i][j].select = false;
}*/
jButton = new Poker[5];
for(int i=0;i<5;i++)
{
jButton[i] = new Poker();
jButton[i].n =i;
//jButton[i].stat =true;
jButton[i].addActionListener(this);
}
jTextField = new JTextField[5];
for(int i=0;i<5;i++)
{
jTextField[i] = new JTextField();
}
try {
jbInit();
this.setSize(800,400);
}
catch(Exception e) {
e.printStackTrace();
}
}
private void jbInit() throws Exception {
xYLayout1.setWidth(790);
xYLayout1.setHeight(358);
jTextField[4].setRequestFocusEnabled(true);
jTextField[4].setEditable(false);
jTextField[4].setText("");
jTextField[3].setVerifyInputWhenFocusTarget(true);
jTextField[3].setEditable(false);
jTextField[3].setText("");
jTextField[3].addActionListener(new MainFrame_jTextField3_actionAdapter(this));
jTextField[1].setEditable(false);
jTextField[1].setText("");
jTextField[1].addActionListener(new MainFrame_jTextField1_actionAdapter(this));
jPanel1.setLayout(xYLayout2);
this.getContentPane().setLayout(xYLayout1);
jTextField6.setVerifyInputWhenFocusTarget(true);
jTextField6.setEditable(false);
jTextField6.setText("你有现金 "+money+"元");
jTextField6.addActionListener(new MainFrame_jTextField6_actionAdapter(this));
jTextField7.setEditable(false);
jTextField7.setText("每次 5元");
jTextField7.addActionListener(new MainFrame_jTextField7_actionAdapter(this));
/*
jButton1.setText("jButton1");
jButton2.setText("jButton1");
jButton3.setText("jButton1");
jButton4.setText("jButton1");
jButton5.setText("jButton1");
*/
jPanel1.setBorder(BorderFactory.createTitledBorder("you are playing"));
jButton6.setText("发牌");
jButton6.addActionListener(new MainFrame_jButton6_actionAdapter(this));
jTextField[2].setEditable(false);
jTextField[2].setText("");
jTextField[0].setEditable(false);
jTextField[0].setText("");
jButton[0].setIcon(back);
jButton[1].setIcon(back);
jButton[2].setIcon(back);
jButton[3].setIcon(back);
jButton[4].setIcon(back);
jLabel1.setAlignmentY((float) 0.8);
jLabel1.setMaximumSize(new Dimension(18, 16));
jLabel1.setOpaque(false);
jLabel1.setPreferredSize(new Dimension(18, 16));
jLabel1.setIconTextGap(4);
jLabel1.setText("");
jLabel1.setVerticalAlignment(javax.swing.SwingConstants.CENTER);
jLabel1.setVerticalTextPosition(javax.swing.SwingConstants.CENTER);
jPanel1.add(jButton[0], new XYConstraints(36, 87, 73, 97));
jPanel1.add(jButton[1], new XYConstraints(145, 87, 73, 97));
jPanel1.add(jButton[2], new XYConstraints(258, 87, 73, 97));
jPanel1.add(jButton[3], new XYConstraints(364, 87, 73, 97));
jPanel1.add(jButton[4], new XYConstraints(462, 87, 73, 97));
jPanel1.add(jTextField6, new XYConstraints(565, 46, 128, 23));
jPanel1.add(jTextField7, new XYConstraints(566, 120, 128, 23));
this.getContentPane().add(jLabel1, new XYConstraints(406, 294, 140, 40));
jPanel1.add(jTextField[0], new XYConstraints(45, 31, 55, 23));
jPanel1.add(jTextField[1], new XYConstraints(154, 31, 55, 23));
jPanel1.add(jTextField[2], new XYConstraints(266, 31, 55, 23));
jPanel1.add(jTextField[3], new XYConstraints(369, 31, 55, 23));
jPanel1.add(jTextField[4], new XYConstraints(470, 31, 55, 23));
this.getContentPane().add(jButton6, new XYConstraints(31, 285, 93, 31));
this.getContentPane().add(jPanel1, new XYConstraints(32, 22, 725, 256));
}
void jTextField3_actionPerformed(ActionEvent e) {
}
void jTextField1_actionPerformed(ActionEvent e) {
}
void jButton6_actionPerformed(ActionEvent e) {
System.out.println("hello----------------------");
if(start ==false)
{
newPoker();
// createIcon();
money -=5;
jTextField6.setText("你有现金 "+money+"元");
System.out.print("******************");
for (int i = 0; i < 5; i++) {
jTextField[i].setText(null);
}
jLabel1.setText(null);
start = true;
}else
{
System.out.println("execute---------------------------");
//pic_back();
execPoker();
shuanfa();
start=false;
}
}
public void shuanfa()
{
int a[] =new int[5];
int b[] =new int [5];
int tmp_a;
int tmp_b;
for (int i = 0; i < 5; i++) {
a[i] = jButton[i].x;
b[i] = jButton[i].y;
}
for(int i=1;i<5;i++)
for(int j=0;j<4;j++)
{
if(b[j]>b[j+1])
{
tmp_b=b[j];b[j]=b[j+1];b[j+1]=tmp_b;
tmp_a=a[j];a[j]=a[j+1];a[j+1]=tmp_a;
}
}
if((b[0]==b[1])&&(b[1]==b[2])&&(b[2]==b[3])||(b[1]==b[2])&&(b[2]==b[3])&&(b[3]==b[4]))
{
money +=150;
jTextField6.setText("你有现金 "+money+"元");
System.out.println("you win "+150);
jLabel1.setText("you win "+150);
}
else if(((b[0]==b[1])&&(b[1]==b[2])&&(b[3]==b[4]))||((b[0]==b[1])&&(b[2]==b[3])&&(b[3]==b[4])))
{
money += 60;
jTextField6.setText("你有现金 " + money + "元");
System.out.println("you win " + 60);
jLabel1.setText("you win "+60);
}
else if((((b[0]==b[1]-1)&&(b[0]==b[2]-2)&&(b[0]==b[3]-3)&&(b[0]==b[4]-4))
&&((a[0]==a[1])&&(a[1]==a[2])&&(a[2]==a[3])&&(a[3]==a[4])))||(
((b[1]==9)&&(b[2]==10)&&(b[3]==11)&&(b[4]==12))&&
(a[0]==a[1])&&(a[0]==a[2])&&(a[0]==a[3])&&(a[0]==a[4])&&(b[0]==0)
))
{
money += 200;
jTextField6.setText("你有现金 " + money + "元");
System.out.println("you win " + 200);
jLabel1.setText("you win "+200);
}
else if((a[0]==a[1])&&(a[1]==a[2])&&(a[2]==a[3])&&(a[3]==a[4]))
{
money += 50;
jTextField6.setText("你有现金 " + money + "元");
System.out.println("you win " + 50);
jLabel1.setText("you win "+50);
}
else if(((b[0]==b[1]-1)&&(b[0]==b[2]-2)&&(b[0]==b[3]-3)&&(b[0]==b[4]-4))
||((b[1]==9)&&(b[2]==10)&&(b[3]==11)&&(b[4]==12)&&(b[0]==0)))
{
money += 40;
jTextField6.setText("你有现金 " + money + "元");
System.out.println("you win " + 40);
jLabel1.setText("you win "+40);
}
else if((b[0]==b[1])&&(b[1]==b[2])||(b[1]==b[2])&&(b[2]==b[3])
||(b[2]==b[3])&&(b[3]==b[4]))
{
money += 30;
jTextField6.setText("你有现金 " + money + "元");
System.out.println("you win " + 30);
jLabel1.setText("you win "+30);
}
else if ((b[0]==b[1])&&(b[2]==b[3])||(b[0]==b[1])&&(b[3]==b[4])||
(b[1]==b[2])&&(b[3]==b[4]))
{
money += 15;
jTextField6.setText("你有现金 " + money + "元");
System.out.println("you win " + 15);
jLabel1.setText("you win "+15);
}
else if (((b[0]==b[1])&&b[0]>9)||((b[1]==b[2])&&b[1]>9)||
((b[2]==b[3])&&b[2]>9)||((b[3]==b[4])&&b[3]>9)||
(b[0]==b[1])&&(b[0]==0))
{
money += 10;
jTextField6.setText("你有现金 " + money + "元");
System.out.println("you win " + 10);
jLabel1.setText("you win "+10);
}
else
{
System.out.println("you lose-----------------");
jLabel1.setText("you lose ");
}
/* for(int i=0;i<5;i++)
{
System.out.println("--------------a[i]------" + a[i]);
System.out.println("--------------b[i]------" + b[i]);
}*/
}
public void execPoker()
{
// pic_back();
for (int i = 0; i < 5; ) {
if(jButton[i].keep ==false)
{
int x = (int) (Math.random() * (4 - 1) + 0.5);
int y = (int) (Math.random() * (13 - 1) + 0.5);
if (pic[x][y].getselect()) {
continue;
}
else
{
// jButton[i].setIcon(null);
//jButton[i].setText("ddddd");
System.out.println("sleep--------");
/* try {
Thread.sleep(1000);
}
catch (InterruptedException ex) {
}*/
pic[x][y].setselect();
jButton[i].setIcon(pic[x][y]);
// jButton[i].setIcon(back);
jButton[i].x = x;
jButton[i].y = y;
i++;
}
}else
{
i++;
}
}
for(int i=0;i<5;i++)
{
jTextField[i].setText(null);
}
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 13; j++) {
pic[i][j].select = false;
}
}
for(int i=0;i<5;i++)
{
jButton[i].stat = true;
jButton[i].keep =false;
}
}
public void pic_back()
{
for (int i = 0; i < 5;i++ ) {
if (jButton[i].keep == false)
{
jButton[i].setIcon(back);
jButton[i].repaint();
System.out.println("@@@@@@@@ "+i);
}
}
}
void jTextField7_actionPerformed(ActionEvent e) {
}
public void actionPerformed(ActionEvent e)
{
Poker pok =(Poker)e.getSource();
int i =pok.x;
int j =pok.y;
int nn=pok.n;
System.out.println("#####################");
if(start == true)
{
if(jButton[nn].stat==true)
{
jTextField[nn].setText("持牌");
pic[i][j].select = true;
System.out.println("select on-------------------"+i);
System.out.println("select on-------------------"+j);
jButton[nn].keep =true;
System.out.println("true______________________");
jButton[nn].stat =false;
}
else
{
jTextField[nn].setText(null);
pic[i][j].select =false;
jButton[nn].stat=true;
System.out.println("select off-------------------"+i);
System.out.println("select off-------------------"+j);
System.out.println("false_______________________");
jButton[nn].keep=false;
}
}
}
public void createIcon(){
// pic = new Picture[row][column];
for (int i = 0; i < 4; i++)
for (int j = 0; j < 13; j++) {
addr = "./src/cards/pic_" + i + "_" + j + ".gif";
pic[i][j] = new Picture(addr);
pic[i][j].zx = i;
pic[i][j].zy = j;
// pic[i][j].select = false;
}
}
public void newPoker()
{
// zero();
for(int i=0;i<5;)
{
int x = (int) (Math.random() * (4 - 1) + 0.5);
int y = (int) (Math.random() * (13- 1) + 0.5);
if(pic[x][y].getselect())
continue;
pic[x][y].setselect();
jButton[i].setIcon(pic[x][y]);
jButton[i].x=x;
jButton[i].y=y;
i++;
}
/* for (int i = 0; i < 4; i++) {
for (int j = 0; j < 13; j++) {
pic[i][j].select =false ;
}
}*/
//start=true;
}
public void zero() {
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 13; j++) {
pic[i][j].setselect();
}
}
}
void jTextField6_actionPerformed(ActionEvent e) {
}
}
class MainFrame_jTextField3_actionAdapter implements java.awt.event.ActionListener {
MainFrame adaptee;
MainFrame_jTextField3_actionAdapter(MainFrame adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jTextField3_actionPerformed(e);
}
}
class MainFrame_jTextField1_actionAdapter implements java.awt.event.ActionListener {
MainFrame adaptee;
MainFrame_jTextField1_actionAdapter(MainFrame adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jTextField1_actionPerformed(e);
}
}
class MainFrame_jButton6_actionAdapter implements java.awt.event.ActionListener {
MainFrame adaptee;
MainFrame_jButton6_actionAdapter(MainFrame adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton6_actionPerformed(e);
}
}
class MainFrame_jTextField7_actionAdapter implements java.awt.event.ActionListener {
MainFrame adaptee;
MainFrame_jTextField7_actionAdapter(MainFrame adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jTextField7_actionPerformed(e);
}
}
class Poker extends JButton
{
int n;//
int x;
int y;
boolean stat=true;
boolean keep=false;
Poker(){
}
Poker(int x,int y){
this.x=x;
this.y=y;
}
}
class Picture extends ImageIcon
{
int zx;
int zy;
boolean select =false;
String a;
Picture(){
}
public Picture(String a){
super(a);
//this.a =a;
}
public boolean getselect(){
return this.select;
}
public void setselect(){
this.select=true;
}
}
class MainFrame_jTextField6_actionAdapter implements java.awt.event.ActionListener {
MainFrame adaptee;
MainFrame_jTextField6_actionAdapter(MainFrame adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jTextField6_actionPerformed(e);
}
}
- poker.rar (211.8 KB)
- 下载次数: 39
相关推荐
在本次分享中,我们将深入探讨一个由学生团队在《面向对象编程》课程中创作的项目——"PokerGame"。这个项目是基于Qt平台构建的,它不仅展示了面向对象编程的核心理念,还体现了团队协作与项目管理的实际应用。通过...
本项目名为"PokerGame_Java",是一款基于Java语言设计的多媒体扑克游戏,遵循三公规则。此游戏不仅展现了Java GUI(图形用户界面)的运用,还深入实践了多线程编程技术,为玩家带来流畅的游戏体验。 首先,让我们...
《T-Antry-PokerGame-V1.0》是一款基于Java Swing技术开发的单机版斗地主游戏。这款软件充分展示了Java在桌面应用领域的强大功能,尤其在图形用户界面(GUI)设计和多线程处理方面的应用。下面将对这款游戏中涉及的...
In this part you are asked to write three classes to be part of a program to play a game of cards.
在本项目"PokerGame"中,我们探讨了一个简单的编程练习,目标是实现一个基础的扑克游戏。这个项目主要使用了Java编程语言,旨在帮助初学者理解面向对象编程、类的设计以及算法的应用。以下是对该项目各个方面的详细...
扑克游戏 扑克游戏评估以取得进步 该评估使用扑克规则评估为玩家发行的5张卡 ...在命令行/术语中,导航到主项目文件夹pokergame-master并运行: pkr-app / target / pkr-app-0.0.1-SNAPSHOT-jar-with-
标题中的"PokerGame.rar"表明这是一个与扑克游戏相关的软件或数据包,可能是一个桌面应用程序或者某种游戏资源。".rar"是流行的压缩文件格式,通常用于集合多个文件或目录到一个可便于传输和存储的单一文件中。在...
PokerGame
编写程序,项目名和类名均为PokerGame。 描述: 共有1幅扑克牌,不包括大王和小王共52张牌。 可能有n个人参与扑克游戏,2。 程序运行时输入n,然后52张牌分别依次分发给n个人。不能整除时,每个人的牌数可以不同,如...
"PokerGame:统一测试"这个项目显然是一个使用C#编写的扑克游戏的测试集,目的是确保游戏逻辑的准确性和稳定性。下面我们将深入探讨C#在游戏开发中的应用以及与扑克游戏相关的编程概念。 首先,C#作为Microsoft .NET...
扑克游戏 因为我正在制作一个扑克游戏作为我 11 年级计算机科学课程的总结,我负责该程序的后端。 我开发了相当复杂的算法,可以检查和分类游戏中不同手牌的扑克等级。 后来我编写了一个程序,通过检查 10 亿只不同...
此html是java程序设计进阶篇上的24点游戏的配套资源。
原Pomelo框架的Unity Demo有bug,无法正常运行。并且API回调在通信线程,使用起来极不方便。 该Demo对官方的Unity API进行了重构,主要功能如下: 1. 所有方法的回调均在主线程(原PomeloClient回调在Socket线程,...
《Delphi编写的多线程小游戏——PokerGame解析》 Delphi,作为一个强大的面向对象的编程环境,因其高效的编译器和丰富的组件库而深受程序员喜爱。在本篇文章中,我们将深入探讨一个由Delphi编写的名为"PokerGame"的...
扑克游戏 部署链接: : 进展中的工作- 描述 这是一个Javascript太空扑克游戏! 这是经典的扑克游戏,而不是德州扑克,在此用户最多可以与其他4个玩家一起玩。 游戏规则及其运作方式 您可以在第一个“开始”板...
MyPokerSolution 这是一个扑克解决方案项目。...Class: org.poker.pokergame.PokerGame如何在Windows中运行将jar和输入文件放在同一文件夹中从CommandLine执行以下命令java -jar poker.jar < PokerInput.txt
本文将深入探讨一个名为"game-theory-poker.zip"的开源项目,该项目是基于2005年的博弈论理论,专门针对头对头限注德州扑克玩家设计的。这个项目包含大约6000行Java代码,为我们揭示了博弈论在扑克游戏中的应用以及...
1. 类(Class):我们可以创建一个名为`PokerGame`的类,它包含发牌的逻辑。在这个类中,我们定义一个静态成员变量`cards`来存储所有的牌,以及三个实例变量`playerHands`表示三位玩家的手牌。 ```csharp class ...
为了实际运行游戏,我们需要创建一个主类(`PokerGame`),在这个类中初始化玩家和牌局,然后进行游戏循环,直到决出胜负。这可能涉及多线程,因为每个玩家可能需要在限定时间内做出决策。 ```java public class ...