Java如何编写骰子程序,急!

来源:百度知道 编辑:UC知道 时间:2024/05/28 03:11:16
用Java编写一个骰子游戏,不用有骰子的图形,能出想1-6随机数就行,编译不要有错误
在线等!!
2楼能在后面加点注释嘛,像import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class MyGuess extends JFrame implements ActionListener{//主类
Random RandomNumber=new Random();//定义Random对象
不胜感激!!

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class MyGuess extends JFrame implements ActionListener{
Container cont;
String str;
int s;
int a;
int conut;
JButton jb1;
JButton jb2;
JTextField jtf1;
JLabel jl1;
public MyGuess(){
this.setTitle("Let's Play Game");
this.setSize(350,400);
this.setDefaultCloseOperation(this.EXIT_ON_CLOSE);
this.setLocationRelativeTo(null);

cont = this.getContentPane();
cont.setLayout(new GridLayout(3,1));
JPanel jp1 = new JPanel();
jp1.setLayout(new FlowLayout(FlowLayout.CENTER,0,20));
jp1.setBorder(BorderFactory.createTitledBorder("Your Guess"));
jtf1 = new JTextField(20);
jp1.add(jtf1);
cont.add(jp1);

JPanel jp2 = new JPanel();
jp2.setLayout(new FlowLayout(FlowLayout.CENTER,0,25));
jp2.setBorder(BorderFactory.createTitledBorde