⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 adder.java

📁 J2ME的游戏原代码!希望能帮助有需要帮助的师兄弟们!
💻 JAVA
字号:
/* * Adder.java * * Created on den 2 juli 2003, 14:06 */package DXBenchmarker;import javax.microedition.midlet.*;import javax.microedition.lcdui.*;import javax.microedition.midlet.MIDlet;import java.io.IOException;/** * * @author  23046803 * @version */public class Adder extends Form implements CommandListener{  private static final Command exitCommand = new Command("Exit", Command.EXIT, 2);  private static final Command okCommand = new Command("OK", Command.OK, 2);    private static final int NUMBER_OF_LOOPS = 1000000;    private Display display;  private Displayable previousDisplay;    private long startTime;  private long endTime;  private long totalTime;    public Adder(Display display, Displayable previousDisplay)  {    super("Addition application");        this.addCommand(exitCommand);    this.addCommand(okCommand);    this.setCommandListener(this);        this.display = display;    this.previousDisplay = previousDisplay;        showStartForm();  }    public void commandAction(Command c, Displayable s)  {    if (c == exitCommand)    {      display.setCurrent(previousDisplay);    }    if (c == okCommand)    {      showPleaseWait();      makeAdditions();    }  }    public void showStartForm()  {    this.append("This test will now run a set of additions, depending upon the platform the test may take as much as one minute!");  }    public void showPleaseWait()  {    while (this.size() > 0)    {      delete(0);    }        this.append("Please wait \n");    this.append("Making calculations (this could take one minute)");  }    public void makeAdditions()  {    int numberOfAdditions = 0;    int a = 1000;    int b = 1;    startTime = System.currentTimeMillis();        for (int x = 0; x < NUMBER_OF_LOOPS; x = x + 1)    {      a = b + 0;      a = b + 1;      a = b + 2;      a = b + 3;      a = b + 4;      a = b + 5;      a = b + 6;      a = b + 7;      a = b + 8;      a = b + 9;    }        endTime = System.currentTimeMillis();    totalTime = endTime - startTime;        numberOfAdditions = 10 * NUMBER_OF_LOOPS;        while (this.size() > 0)    {      delete(0);    }        this.append("Total time (ms): " + totalTime + "\n");    this.append("Additions: " + numberOfAdditions + "\n");    this.append("Additions / millisecond: " + numberOfAdditions / totalTime + "\n");  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -