王朝知道
分享
 
 
 

寻街头水果赌币机的程序代码

王朝知道·作者佚名  2010-07-08  
宽屏版  字体: |||超大  
 
分类: 电脑/网络 >> 程序设计 >> 其他编程语言
 
问题描述:

因为要编写类似程序故征询

参考答案:

给你我以前写的一个小玩意参考呵呵,是看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();

}

}

小贴士:① 若网友所发内容与教科书相悖,请以教科书为准;② 若网友所发内容与科学常识、官方权威机构相悖,请以后者为准;③ 若网友所发内容不正确或者违背公序良俗,右下举报/纠错。
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
如何用java替换看不见的字符比如零宽空格&#8203;十六进制U+200B
 干货   2023-09-10
网页字号不能单数吗,网页字体大小为什么一般都是偶数
 干货   2023-09-06
java.lang.ArrayIndexOutOfBoundsException: 4096
 干货   2023-09-06
Noto Sans CJK SC字体下载地址
 干货   2023-08-30
window.navigator和navigator的区别是什么?
 干货   2023-08-23
js获取referer、useragent、浏览器语言
 干货   2023-08-23
oscache遇到404时会不会缓存?
 干货   2023-08-23
linux下用rm -rf *删除大量文件太慢怎么解决?
 干货   2023-08-08
刀郎新歌破世界纪录!
 娱乐   2023-08-01
js实现放大缩小页面
 干货   2023-07-31
生成式人工智能服务管理暂行办法
 百态   2023-07-31
英语学习:过去完成时The Past Perfect Tense举例说明
 干货   2023-07-31
Mysql常用sql命令语句整理
 干货   2023-07-30
科学家复活了46000年前的虫子
 探索   2023-07-29
英语学习:过去进行时The Past Continuous Tense举例说明
 干货   2023-07-28
meta name="applicable-device"告知页面适合哪种终端设备:PC端、移动端还是自适应
 干货   2023-07-28
只用css如何实现打字机特效?
 百态   2023-07-15
css怎么实现上下滚动
 干货   2023-06-28
canvas怎么画一个三角形?
 干货   2023-06-28
canvas怎么画一个椭圆形?
 干货   2023-06-28
canvas怎么画一个圆形?
 干货   2023-06-28
canvas怎么画一个正方形?
 干货   2023-06-28
中国河南省郑州市金水区蜘蛛爬虫ip大全
 干货   2023-06-22
javascript简易动态时间代码
 干货   2023-06-20
感谢员工的付出和激励的话怎么说?
 干货   2023-06-18
 
>>返回首页<<
 
 
 
静静地坐在废墟上,四周的荒凉一望无际,忽然觉得,凄凉也很美
© 2005- 王朝网络 版权所有