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

📄 midptoolkit.java

📁 j2me实现的一款小游戏
💻 JAVA
字号:
package istarion.midlet;

import java.util.*;
import java.io.*;
import javax.microedition.io.*;
import istarion.frontend.Toolkit;


public class MIDPToolkit extends Toolkit
{
	private Random __rnd = new Random();

	private HttpConnection __connection = null;
	private OutputStream __outstream = null;

	private static int __dbgLevel = 0;

	/**
	 * Roles a D b + c.
	 */
	public int rollDice(int a, int b, int c)
	{
		return a * (Math.abs(__rnd.nextInt() % b) + 1) + c;
	}


	/**
	 * Produces a random sequence of int.
	 */
	public int[] getRandomIntSequence(int size)
	{
		int[] sequence = new int[size];
		int tmprnd;
		int tmp;

		for (int i = 0; i < size; i++)
		{
			sequence[i] = i;
		}

		for (int i = 0; i < 4; i++)
		{
			tmprnd = Math.abs(__rnd.nextInt() % size);
			tmp = sequence[i];
			sequence[i] = sequence[tmprnd];
			sequence[tmprnd] = tmp;
		}

		return sequence;
	}


	/**
	 * Sets the debug level. Zero means no debug.
	 */
	public void setDebugLevel(int lvl)
	{
		__dbgLevel = lvl;
	}

	/**
	 * Remote debugging over HTTP-Connection at localhost.
	 */
	public void debug(String dbg)
	{
		if (__dbgLevel == 0)
			return;
		try
		{
			if (__connection == null)
			{
	        	__connection = (HttpConnection)Connector.open("http://localhost");
    	    	__outstream = __connection.openOutputStream();
        	}

        	// Getting the output stream may flush the headers
        	__outstream.write(dbg.getBytes());
        	__outstream.flush();
        } catch (IOException io) {
        	System.err.println("Connection to localhost:80 failed");
        }
	}

}

⌨️ 快捷键说明

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