求一个用java实现游戏“石头剪子布”的源代码
如果能有简单的图形实现,我可以另外加20分~~谢谢~~方便的话请发到我的邮箱xiaodaomi-1@yahoo.com.cndoSFC()函数我不想出来的呀,你就好人做到...
如果能有简单的图形实现,我可以另外加20分~~
谢谢~~
方便的话请发到我的邮箱xiaodaomi-1@yahoo.com.cn
doSFC()函数我不想出来的呀,你就好人做到底吧,求求你了~~呜呜 展开
谢谢~~
方便的话请发到我的邮箱xiaodaomi-1@yahoo.com.cn
doSFC()函数我不想出来的呀,你就好人做到底吧,求求你了~~呜呜 展开
展开全部
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JApplet;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
public class Test extends JApplet{
private static final long serialVersionUID = 1L;
JButton btnStone = new JButton("石头");
JButton btnForfex = new JButton("剪刀");
JButton btnCloth = new JButton("布");
JLabel jl = new JLabel();
JPanel jpl = new JPanel();
public void init(){
jpl.add(jl,BorderLayout.NORTH);
jpl.add(btnStone,BorderLayout.SOUTH);
jpl.add(btnForfex,BorderLayout.SOUTH);
jpl.add(btnCloth,BorderLayout.SOUTH);
this.getContentPane().add(jpl);
btnForfex.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
doSFC();
if(doSFC()==1){
jl.setText("石头");
JOptionPane.showMessageDialog(null, "平手");
}
if(doSFC()==2){
jl.setText("剪刀");
JOptionPane.showMessageDialog(null, "你赢了");
}
if(doSFC()==3){
jl.setText("布");
JOptionPane.showMessageDialog(null, "你输了");
}
}
});
btnStone.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
doSFC();
if(doSFC()==1){
jl.setText("石头");
JOptionPane.showMessageDialog(null, "你赢了");
}
if(doSFC()==2){
jl.setText("剪刀");
JOptionPane.showMessageDialog(null, "你输了");
}
if(doSFC()==3){
jl.setText("布");
JOptionPane.showMessageDialog(null, "平手");
}
}
});
btnCloth.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
doSFC();
if(doSFC()==1){
jl.setText("石头");
JOptionPane.showMessageDialog(null, "你输了");
}
if(doSFC()==2){
jl.setText("剪刀");
JOptionPane.showMessageDialog(null, "平手");
}
if(doSFC()==3){
jl.setText("布");
JOptionPane.showMessageDialog(null, "你赢了");
}
}
});
}
public int doSFC(){//随机生成1、2、3
int n = 0 ;
//
return n;
}
}
doSFC()那个函数我没有想出来 你自己实现一下 应该不难
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JApplet;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
public class Test extends JApplet{
private static final long serialVersionUID = 1L;
JButton btnStone = new JButton("石头");
JButton btnForfex = new JButton("剪刀");
JButton btnCloth = new JButton("布");
JLabel jl = new JLabel();
JPanel jpl = new JPanel();
public void init(){
jpl.add(jl,BorderLayout.NORTH);
jpl.add(btnStone,BorderLayout.SOUTH);
jpl.add(btnForfex,BorderLayout.SOUTH);
jpl.add(btnCloth,BorderLayout.SOUTH);
this.getContentPane().add(jpl);
btnForfex.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
doSFC();
if(doSFC()==1){
jl.setText("石头");
JOptionPane.showMessageDialog(null, "平手");
}
if(doSFC()==2){
jl.setText("剪刀");
JOptionPane.showMessageDialog(null, "你赢了");
}
if(doSFC()==3){
jl.setText("布");
JOptionPane.showMessageDialog(null, "你输了");
}
}
});
btnStone.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
doSFC();
if(doSFC()==1){
jl.setText("石头");
JOptionPane.showMessageDialog(null, "你赢了");
}
if(doSFC()==2){
jl.setText("剪刀");
JOptionPane.showMessageDialog(null, "你输了");
}
if(doSFC()==3){
jl.setText("布");
JOptionPane.showMessageDialog(null, "平手");
}
}
});
btnCloth.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
doSFC();
if(doSFC()==1){
jl.setText("石头");
JOptionPane.showMessageDialog(null, "你输了");
}
if(doSFC()==2){
jl.setText("剪刀");
JOptionPane.showMessageDialog(null, "平手");
}
if(doSFC()==3){
jl.setText("布");
JOptionPane.showMessageDialog(null, "你赢了");
}
}
});
}
public int doSFC(){//随机生成1、2、3
int n = 0 ;
//
return n;
}
}
doSFC()那个函数我没有想出来 你自己实现一下 应该不难
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询