• 大小: 166KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-05-11
  • 语言: 其他
  • 标签: java课设  GUI  

资源简介

完成一个猜数字的GUI游戏。 开始游戏后,产生一个没有重复数字的4位随机数,用户每猜一个数字,显示出“完全猜中的数字个数”和“猜中数字但位置错误的数字个数”,比如nAmB,数字n表示猜中的位置正确的数字个数,数字m表示数字正确而位置不对的数字个数。例如,正确答案为5234,如果用户猜5346,则显示:1A2B,数字1表示数字5及其位置猜对了,数字3和4这两个数字猜对了,但是位置没对,记为2B。然后,用户根据游戏提示的信息继续猜,直到猜中为止。同时设计规则,根据猜中的次数计算积分,并可以显示不同用户的排行榜。 注意:因为BGM因为太大被我去掉了

资源截图

代码片段和文件信息


import java.awt.Graphics;
import java.awt.Image;
import static java.lang.Thread.sleep;
import java.util.logging.Level;
import java.util.logging.Logger;

/*
 * To change this license header choose License Headers in Project Properties.
 * To change this template file choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author 17864
 */
public class Adjust extends javax.swing.JPanel {
    //Game game;
    /**
     * Creates new form Adjust
     */
    Image adimage;
    private PressThread thread;
    private byte value=5;

    public byte getValue() {
        return value;
    }
    private boolean pressed=false;
    public Adjust() {
        initComponents();
        this.ShowValue(value);
        thread=new PressThread(this);
       // this.game=game;
       // adimage=Game.ast.getImage(“adjust“);
    }
    private void addValue()
    {
        value++;
        if(value>=10)value=0;
    }
    private void cutValue()
    {
        value--;
        if(value<0)value=9;
    }
    private void ShowValue(byte v)
    {
        jLabel3.setText(““+v);
    }
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings(“unchecked“)
    // //GEN-BEGIN:initComponents
    private void initComponents() {

        jButton5 = new javax.swing.JButton();
        jButton6 = new javax.swing.JButton();
        jLabel3 = new javax.swing.JLabel();

        setBackground(new java.awt.Color(210 186 60));
        setBorder(null);
        setPreferredSize(new java.awt.Dimension(125 200));

        jButton5.setIcon(new javax.swing.ImageIcon(getClass().getResource(“/image/up.jpg“))); // NOI18N
        jButton5.setBorder(null);
        jButton5.setBorderPainted(false);
        jButton5.setIconTextGap(0);
        jButton5.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                jButton5MousePressed(evt);
            }
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                jButton5MouseReleased(evt);
            }
        });

        jButton6.setIcon(new javax.swing.ImageIcon(getClass().getResource(“/image/down.png“))); // NOI18N
        jButton6.setBorder(null);
        jButton6.setBorderPainted(false);
        jButton6.setIconTextGap(0);
        jButton6.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                jButton6MousePressed(evt);
            }
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                jButton6MouseReleased(evt);
            }
        });

        jLabel3.setBackground(new java.awt.Color(102 102 0));
        jLabel3.setFont(new java.awt.Font(“微软雅黑“ 1 64)); // NOI18

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2017-12-31 11:11  GuessWhat\
     文件        3612  2017-12-31 11:11  GuessWhat\build.xml
     文件          85  2017-03-29 22:07  GuessWhat\manifest.mf
     目录           0  2017-06-10 10:34  GuessWhat\nbproject\
     文件       79325  2017-12-31 11:11  GuessWhat\nbproject\build-impl.xml
     文件         475  2017-12-31 11:11  GuessWhat\nbproject\genfiles.properties
     目录           0  2017-06-10 10:34  GuessWhat\nbproject\private\
     文件         111  2017-12-31 11:10  GuessWhat\nbproject\private\private.properties
     文件         485  2017-12-31 11:13  GuessWhat\nbproject\private\private.xml
     文件        2629  2017-12-31 11:11  GuessWhat\nbproject\project.properties
     文件         517  2017-12-31 11:11  GuessWhat\nbproject\project.xml
     目录           0  2017-06-10 10:34  GuessWhat\src\
     文件        5724  2017-04-08 12:56  GuessWhat\src\Adjust.form
     文件        7436  2017-04-10 15:51  GuessWhat\src\Adjust.java
     文件        1869  2017-04-17 11:14  GuessWhat\src\Asserts.java
     文件        1489  2017-04-17 15:35  GuessWhat\src\BGM.java
     文件        1406  2017-04-03 17:02  GuessWhat\src\ControlPanel.form
     文件        1589  2017-04-03 17:02  GuessWhat\src\ControlPanel.java
     文件       20812  2017-04-24 15:55  GuessWhat\src\Game.form
     文件       21404  2017-05-10 22:03  GuessWhat\src\Game.java
     文件        3407  2017-12-31 11:11  GuessWhat\src\GuessWhat.java
     文件        6540  2017-04-24 11:26  GuessWhat\src\Load.form
     文件        7686  2017-04-24 15:51  GuessWhat\src\Load.java
     文件        1151  2017-04-10 16:50  GuessWhat\src\NumGenerator.java
     文件        1094  2017-04-04 11:21  GuessWhat\src\User.java
     文件        5641  2017-04-24 11:28  GuessWhat\src\UserManager.java
     目录           0  2017-06-10 10:34  GuessWhat\src\image\
     文件        5476  2017-04-03 16:03  GuessWhat\src\image\adjust.jpg
     文件       81821  2017-04-03 12:13  GuessWhat\src\image\background.jpg
     文件       18281  2017-04-15 10:23  GuessWhat\src\image\dialog.jpg
     文件        5562  2017-04-03 15:18  GuessWhat\src\image\down.jpg
............此处省略10个文件信息

评论

共有 条评论