卡尔费休法计算公式:寻街头水果赌币机的程序代码

来源:百度文库 编辑:神马品牌网 时间:2024/04/30 08:11:21
因为要编写类似程序故征询

给你我以前写的一个小玩意参考呵呵,是看mop的受启发搞着玩的:(下面是核心的算法方面的类,没什么东西,就一个随机接口IQ,实现看你自己怎么做了,想别人不赢就自己实现那个接口吧^Q^,还有个frmMain.java是JBuilder自动生成的界面类,很大,我就没传上来了,反正你也就要算法,如果你要界面你就写信给我我把这个文件连工程文件和图片都发给你)

---------------------
Clock.java
---------------------
package zzz;

/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2005</p>
* <p>Company: </p>
* @author Basara
* @version 1.0
*/
import java.util.Timer;
import java.util.TimerTask;

public class Clock {

private final Timer timer = new Timer();
private final int clock;

public Clock(int clock) {
this.clock = clock;
}

public void start() {
timer.schedule(new TimerTask() {
public void run() {
playSound();
timer.cancel();
}
private void playSound() {
System.out.println("Your egg is ready!");
// Start a new thread to play a sound...
}
}
, clock);
}

public static void main(String[] args) {
Clock eggTimer = new Clock(5000);
eggTimer.start();
}

}

-------------
DataImpl.java
-------------
package zzz;

import java.util.Random;

/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2005</p>
* <p>Company: </p>
* @author Basara
* @version 1.0
*/

public class DataImpl {
public DataImpl() {
ele[0] = new Element(1, 2, 0, 10);
ele[1] = new Element(2, 2, 1, 2);
ele[2] = new Element(3, 8, 1, 25);
ele[3] = new Element(4, 8, 0, 100);
ele[4] = new Element(5, 0, 2, 0);
ele[5] = new Element(6, 1, 0, 5);
ele[6] = new Element(7, 1, 1, 2);
ele[7] = new Element(8, 3, 0, 15);
ele[8] = new Element(9, 5, 0, 25);
ele[9] = new Element(10, 5, 1, 2);
ele[10] = new Element(11, 4, 0, 20);
ele[11] = new Element(12, 1, 0, 5);
ele[12] = new Element(13, 2, 1, 2);
ele[13] = new Element(14, 2, 0, 10);
ele[14] = new Element(15, 0, 2, 0);
ele[15] = new Element(16, 4, 0, 20);
ele[16] = new Element(17, 7, 1, 2);
ele[17] = new Element(18, 7, 0, 50);
ele[18] = new Element(19, 1, 0, 5);
ele[19] = new Element(20, 3, 1, 2);
ele[20] = new Element(21, 3, 0, 15);
ele[21] = new Element(22, 6, 0, 30);
ele[22] = new Element(23, 6, 1, 2);
ele[23] = new Element(24, 1, 2, 0);
ele[24] = new Element(25, 1, 1, 2);
ele[25] = new Element(26, 4, 1, 2);
}

public void clearPush() {
IQCount = 0;
for (int i = 0; i < 8; i++) {
push[i] = 0;
}
}

public int bingo(int count) {
if (ele[count - 1].getType() == 2) {
//do bonus
return 0;
}

//System.out.println(push[ele[count - 1].getValue() - 1]+"*"+ele[count - 1].getCash()+"\n");
return
push[ele[count - 1].getValue() - 1] * ele[count - 1].getCash();
}

public boolean IQ(int count) {
IQCount++;
if (IQCount > 10) {
return true;
}
// if (r.nextInt(3) == 2) {
// System.out.println(count);
// return true;
// }
// return false;
//
if (getPushNum() > 5 && ele[count - 1].getType() != 1) {
if (r.nextInt(4) != 1) {
return false;
}
}
//
if (push[ele[count - 1].getValue() - 1] > 5 &&
ele[count - 1].getType() != 1) {
if (r.nextInt(2) == 1) {
return false;
}
}
//
if(ele[count - 1].getValue()>4 && push[ele[count - 1].getValue() - 1] > 0 &&
ele[count - 1].getType() != 1){
if (r.nextInt(2) == 1) {
return false;
}
}

return true;
}

public void setPush(int value, int c) {
push[value - 1] += c;
}

public void setPush(int value) {
push[value - 1]++;
}

public String getValue(int count) {
if (ele[count - 1].getType() < 2) {
return String.valueOf(ele[count - 1].getValue());
}
else {
return ele[count - 1].getValue() == 0 ? "?" : "X";
}
}

private int getPushNum() {
int Num = 0;
for (int i = 0; i < 8; i++) {
if (push[i] > 0) {
Num++;
}
}
return Num;
}

///////////////////////////////////////////////////////////////////////////////
private int IQCount = 0;
private int[] push = new int[8];
private Element ele[] = new Element[26];
private static Random r = new Random();
}

-----------------------
Element.java
-----------------------
package zzz;

/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2005</p>
* <p>Company: </p>
* @author Basara
* @version 1.0
*/

public class Element {
private Element() {
}

public Element(int co, int va, int ty, int ca) {
count = co;
value = va;
type = ty;
cash = ca;
}

public int getCount() {
return count;
}

public int getValue() {
return value;
}

public int getType() {
return type;
}

public int getCash() {
return cash;
}

private int count = 0;
private int value = 0;
private int type = 0; //0 大,1 小,2 柱头
private int cash = 0;
}

------------------------
FrameMain_AboutBox.java
------------------------
package zzz;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;

/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2005</p>
* <p>Company: </p>
* @author Basara
* @version 1.0
*/

public class FrameMain_AboutBox extends JDialog implements ActionListener {

JPanel panel1 = new JPanel();
JPanel panel2 = new JPanel();
JPanel insetsPanel1 = new JPanel();
JPanel insetsPanel2 = new JPanel();
JPanel insetsPanel3 = new JPanel();
JButton button1 = new JButton();
JLabel imageLabel = new JLabel();
JLabel label1 = new JLabel();
JLabel label2 = new JLabel();
JLabel label3 = new JLabel();
JLabel label4 = new JLabel();
ImageIcon image1 = new ImageIcon();
BorderLayout borderLayout1 = new BorderLayout();
BorderLayout borderLayout2 = new BorderLayout();
FlowLayout flowLayout1 = new FlowLayout();
GridLayout gridLayout1 = new GridLayout();
String product = "幸运转转转";
String version = "1.0";
String copyright = "Copyright (c) 2005 Designed By 鬼火狼烟";
String comments = "";
public FrameMain_AboutBox(Frame parent) {
super(parent);
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
//Component initialization
private void jbInit() throws Exception {
image1 = new ImageIcon(FrameMain.class.getResource("about.png"));
imageLabel.setIcon(image1);
this.setTitle("关于本程序");
panel1.setLayout(borderLayout1);
panel2.setLayout(borderLayout2);
insetsPanel1.setLayout(flowLayout1);
insetsPanel2.setLayout(flowLayout1);
insetsPanel2.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
gridLayout1.setRows(4);
gridLayout1.setColumns(1);
label1.setFont(new java.awt.Font("Dialog", 1, 20));
label1.setForeground(Color.red);
label1.setText(product);
label2.setPreferredSize(new Dimension(40, 16));
label2.setRequestFocusEnabled(true);
label2.setText("版本"+version);
label3.setOpaque(false);
label3.setText(copyright);
label4.setText(comments);
insetsPanel3.setLayout(gridLayout1);
insetsPanel3.setBorder(BorderFactory.createEmptyBorder(10, 60, 10, 10));
button1.setText("Ok");
button1.addActionListener(this);
insetsPanel2.add(imageLabel, null);
panel2.add(insetsPanel2, BorderLayout.WEST);
this.getContentPane().add(panel1, null);
insetsPanel3.add(label1, null);
insetsPanel3.add(label2, null);
insetsPanel3.add(label3, null);
insetsPanel3.add(label4, null);
panel2.add(insetsPanel3, BorderLayout.CENTER);
insetsPanel1.add(button1, null);
panel1.add(insetsPanel1, BorderLayout.SOUTH);
panel1.add(panel2, BorderLayout.NORTH);
setResizable(true);
}
//Overridden so we can exit when window is closed
protected void processWindowEvent(WindowEvent e) {
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
cancel();
}
super.processWindowEvent(e);
}
//Close the dialog
void cancel() {
dispose();
}
//Close the dialog on a button event
public void actionPerformed(ActionEvent e) {
if (e.getSource() == button1) {
cancel();
}
}
}
-----------------------------
zzz.java
--------------------------------
package zzz;

import javax.swing.UIManager;
import java.awt.*;
import net.sourceforge.mlf.metouia.*;

/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2005</p>
* <p>Company: </p>
* @author Basara
* @version 1.0
*/

public class zzz {
boolean packFrame = false;

//Construct the application
public zzz() {
FrameMain frame = new FrameMain();
//Validate frames that have preset sizes
//Pack frames that have useful preferred size info, e.g. from their layout
if (packFrame) {
frame.pack();
}
else {
frame.validate();
}
//frame.setDefaultLookAndFeelDecorated(true);
//Center the window
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Dimension frameSize = frame.getSize();
if (frameSize.height > screenSize.height) {
frameSize.height = screenSize.height;
}
if (frameSize.width > screenSize.width) {
frameSize.width = screenSize.width;
}
frame.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
frame.setVisible(true);
}
//Main method
public static void main(String[] args) {
try {
//UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
UIManager.setLookAndFeel(new MetouiaLookAndFeel());
}
catch(Exception e) {
e.printStackTrace();
}
new zzz();
}
}

你好 楼主
帮你查查

涉江采芙蓉,兰泽多芳草。

采之欲遗谁,所思在远道。

还顾望旧乡,长路漫浩浩。





追答


你说的游/戏我在金脉玩的,金脉娱乐开了好几年了
都没有出过问/题,信/誉好,游/戏多。








可以www.jialebi07.info


我有一款该类机器的ROM,QQ3626999我发给你

你是不是骗点钱呀?

啊,这也要代码?