求J2ME游戏代码
求J2ME游戏代码,小型简单的就可以了,要能运行啊,拜托了,发到邮箱:372267579@qq.com...
求J2ME游戏代码,小型简单的就可以了,要能运行啊,拜托了,发到邮箱:372267579@qq.com
展开
5个回答
展开全部
你是选择继续,还是停留?不管如何,世界的命运已经掌握在你的手中。当战机翱翔在天际之时,就是敌人的阴谋破灭的时刻!史上最经典的射击游戏。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2011-11-26
展开全部
import javax.swing.JOptionPane;
public class GuessNumber
{
public static void main (String args[ ])
{
JOptionPane.showMessageDialog(null, "给你一个1至100之间的整数,请猜测这个数");
int realNumber=(int)(Math.random()*100)+1;
int yourGuess=0;
String str=JOptionPane.showInputDialog("输入您的猜测:");
yourGuess=Integer.parseInt(str);
while(yourGuess!=realNumber) //循环条件
{
if(yourGuess>realNumber) //条件代码
{
str=JOptionPane.showInputDialog("猜大了,再输入你的猜测:");
yourGuess=Integer.parseInt(str);
}
else if(yourGuess<realNumber) //条件代码
{
str=JOptionPane.showInputDialog("猜小了,再输入你的猜测:");
yourGuess=Integer.parseInt(str);
}
}
JOptionPane.showMessageDialog(null, "猜对了!该数为:"+realNumber);
}
}
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
public class GuessNumberFrame extends Frame implements ActionListener,WindowListener,KeyListener{
Button buttonGetNumber,buttonEnter;
Label labelShow;
TextField textInput;
int realNumber;
public GuessNumberFrame() {
super("猜数字游戏");
this.setSize(200,180);
this.setLocation(300,300);
this.setBackground(Color.lightGray);
int width=Toolkit.getDefaultToolkit().getScreenSize().width;
int height=Toolkit.getDefaultToolkit().getScreenSize().height;
this.setLocation((width-300)/2,(height-310)/2);
this.setResizable(false);
this.setLayout(new FlowLayout(1,5,15));
buttonGetNumber=new Button("得到一个随机数");
this.add(buttonGetNumber);
buttonGetNumber.addActionListener(this);
labelShow=new Label("欢迎使用,猜数字游戏:",Label.CENTER);
labelShow.setBackground(Color.orange);
this.add(labelShow);
textInput=new TextField(10);
this.add(textInput);
textInput.addKeyListener(this);
buttonEnter=new Button("确定");
this.add(buttonEnter);
buttonEnter.addActionListener(this);
this.addWindowListener(this);
this.setVisible(true);
}
public void actionPerformed(ActionEvent e) {
if(e.getSource()==buttonGetNumber){
realNumber=(int)(Math.random()*100)+1;
labelShow.setText("请输入你的猜测");
textInput.requestFocus();
}
if(e.getSource()==buttonEnter){
eventc();
}
}
public void keyPressed(KeyEvent e) {
if(e.getKeyCode()==KeyEvent.VK_ENTER){
eventc();
}
}
public void eventc(){
try{
int guess=Integer.parseInt(textInput.getText());
if(guess==realNumber){
labelShow.setText("猜对了");
}
else if (guess>realNumber) {
labelShow.setText("猜大了");
textInput.requestFocus();
}
else if (guess<realNumber) {
labelShow.setText("猜小了");
textInput.requestFocus();
}
}catch (NumberFormatException e1) {
labelShow.setText("请重新输入数字");
}
}
public void windowClosing(WindowEvent e) {
System.exit(0);
}
public void windowActivated(WindowEvent e) {}
public void windowClosed(WindowEvent e) {}
public void windowDeactivated(WindowEvent e) {}
public void windowDeiconified(WindowEvent e) {}
public void windowIconified(WindowEvent e) {}
public void windowOpened(WindowEvent e) {}
public void keyReleased(KeyEvent e) {}
public void keyTyped(KeyEvent e) {}
}
class GuessNumberFrame_ex{
public static void main(String[] args){
new GuessNumberFrame();
}
}
public class GuessNumber
{
public static void main (String args[ ])
{
JOptionPane.showMessageDialog(null, "给你一个1至100之间的整数,请猜测这个数");
int realNumber=(int)(Math.random()*100)+1;
int yourGuess=0;
String str=JOptionPane.showInputDialog("输入您的猜测:");
yourGuess=Integer.parseInt(str);
while(yourGuess!=realNumber) //循环条件
{
if(yourGuess>realNumber) //条件代码
{
str=JOptionPane.showInputDialog("猜大了,再输入你的猜测:");
yourGuess=Integer.parseInt(str);
}
else if(yourGuess<realNumber) //条件代码
{
str=JOptionPane.showInputDialog("猜小了,再输入你的猜测:");
yourGuess=Integer.parseInt(str);
}
}
JOptionPane.showMessageDialog(null, "猜对了!该数为:"+realNumber);
}
}
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
public class GuessNumberFrame extends Frame implements ActionListener,WindowListener,KeyListener{
Button buttonGetNumber,buttonEnter;
Label labelShow;
TextField textInput;
int realNumber;
public GuessNumberFrame() {
super("猜数字游戏");
this.setSize(200,180);
this.setLocation(300,300);
this.setBackground(Color.lightGray);
int width=Toolkit.getDefaultToolkit().getScreenSize().width;
int height=Toolkit.getDefaultToolkit().getScreenSize().height;
this.setLocation((width-300)/2,(height-310)/2);
this.setResizable(false);
this.setLayout(new FlowLayout(1,5,15));
buttonGetNumber=new Button("得到一个随机数");
this.add(buttonGetNumber);
buttonGetNumber.addActionListener(this);
labelShow=new Label("欢迎使用,猜数字游戏:",Label.CENTER);
labelShow.setBackground(Color.orange);
this.add(labelShow);
textInput=new TextField(10);
this.add(textInput);
textInput.addKeyListener(this);
buttonEnter=new Button("确定");
this.add(buttonEnter);
buttonEnter.addActionListener(this);
this.addWindowListener(this);
this.setVisible(true);
}
public void actionPerformed(ActionEvent e) {
if(e.getSource()==buttonGetNumber){
realNumber=(int)(Math.random()*100)+1;
labelShow.setText("请输入你的猜测");
textInput.requestFocus();
}
if(e.getSource()==buttonEnter){
eventc();
}
}
public void keyPressed(KeyEvent e) {
if(e.getKeyCode()==KeyEvent.VK_ENTER){
eventc();
}
}
public void eventc(){
try{
int guess=Integer.parseInt(textInput.getText());
if(guess==realNumber){
labelShow.setText("猜对了");
}
else if (guess>realNumber) {
labelShow.setText("猜大了");
textInput.requestFocus();
}
else if (guess<realNumber) {
labelShow.setText("猜小了");
textInput.requestFocus();
}
}catch (NumberFormatException e1) {
labelShow.setText("请重新输入数字");
}
}
public void windowClosing(WindowEvent e) {
System.exit(0);
}
public void windowActivated(WindowEvent e) {}
public void windowClosed(WindowEvent e) {}
public void windowDeactivated(WindowEvent e) {}
public void windowDeiconified(WindowEvent e) {}
public void windowIconified(WindowEvent e) {}
public void windowOpened(WindowEvent e) {}
public void keyReleased(KeyEvent e) {}
public void keyTyped(KeyEvent e) {}
}
class GuessNumberFrame_ex{
public static void main(String[] args){
new GuessNumberFrame();
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你上百度找下CNSD 在这里能找到不少J2ME的游戏代码的 有不少人在这里共享
追问
我去了,但是申请不了账号,老说我验证邮箱不行。。。
追答
不好意思打错给你了是CSDN 这里
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询