亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? carstore.java

?? 一個非常好的賽車游戲代碼
?? JAVA
字號:
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.io.*;
import javax.microedition.rms.*;
import java.io.*;


public class CarStore
{
    // These two static final ints will
    // be used to filter the records via
    // a RecordFilter implementation.
    public static final int CASH_RECORD = 1;
    public static final int WEAPON_RECORD = 2;

    // The player's current weapons
    private Weapon[] weapons;

    // The player's current cash
    private int cash = 0;

    // Build a new CarStore and set the
    // members
    CarStore() 
    {
    }

    // Writes the cash and weapon data to a new
    // RecordStore.
    public void writeToStore()
    {
        try
        {
            // Let's make sure we're dealing with a fresh new RecordStore
            // (since we're still relying a little on recordId ordering)
            // and remove it if it's still in device storage.
            RecordStore.deleteRecordStore("Car");
        } 
        catch (RecordStoreException rse)
        {
            // This probably means we haven't created a store yet.
		System.err.println(rse);
        }

        RecordStore carDB = null;

        // Now we're ready
        try
        {

            // Now we'll create a new one.
            carDB = RecordStore.openRecordStore( "Car", true );

            // Build some reusable data handling objects.
            ByteArrayOutputStream bout = new ByteArrayOutputStream();
            DataOutputStream dout = new DataOutputStream(bout);
            byte[] data = null;

            // First, we're going to write the player's
            // current cash to the car's RecordStore
            // We'll id the record as a cash record...
            dout.writeByte(CASH_RECORD);

            // and then write the cash amount
            dout.writeInt(cash);

            // and now bundle the Stream into a byte
            // array and write a new record.  It's
            // the very first record in the RecordStore,
            // so we know it'll have the recordId of 1.
            data = bout.toByteArray();

            // Add the array to the RecordStore
            carDB.addRecord(data, 0, data.length );

            // and reset the Streams to
            // properly handle the Weapons.
            bout.reset();

            // Iterate through the car's Weapons array
            for (int i = 0; i < weapons.length; i++)
            {
                // Write the weapon record tag..
                dout.writeByte(WEAPON_RECORD);

                // Write the weapon type...
                dout.writeInt(weapons[i].getWeaponType());

                // Write the weapon's ammo
                dout.writeInt(weapons[i].getWeaponAmmo());

                // Write the Weapon's time value
                dout.writeInt(weapons[i].getWeaponTime());
                
                // Write the weapon's name
                dout.writeUTF(weapons[i].getName());
                
                // Write the weapon's description
                dout.writeUTF(weapons[i].getDescription());

                dout.flush();

                // Pack the Byte Stream (aka the Data Stream)
                // into the data byte array...
                data = bout.toByteArray();

                // Add the array to the RecordStore
                carDB.addRecord(data, 0, data.length );

                // and reset the Streams to
                // properly handle the next Weapon.
                bout.reset();
            }
            carDB.closeRecordStore();
            dout.close();
            bout.close();

        }
        catch (Exception e)
        {
		try { carDB.closeRecordStore(); } catch (Exception e2) { }
            e.printStackTrace();
        }
    }

    public boolean readStore()
    {
        RecordStore carDB = null;
        try
        {
            // Open the RecordStore built above...
            carDB = RecordStore.openRecordStore( "Car", false );

            // Build some reusable data handling objects.
            ByteArrayInputStream bin = null;
            DataInputStream din = null;
            byte[] data = null;

            // First, we'll get the cash record out and set
            // the cash value.  Remember that this record
            // was added before any other so we know it's
            // at recordId == 1.
            data = carDB.getRecord(1);

            // Set up the streams to read back the
            // stored variables
            bin = new ByteArrayInputStream(data);
            din = new DataInputStream(bin);

            // discard the CASH_RECORD byte
            din.readByte();

            // and now grab the actual cash value stored.
            cash = din.readInt();
            System.out.println("Cash: "+cash);

            // clean up for the weapons handling
            din.close();
            bin.close();

            // Prepare the Weapons array for the new data
            // (We build it to (getNumRecords()-1) to account
            // for the cash record.)
            weapons = new Weapon[carDB.getNumRecords()-1];
            // The following sets up a RecordEnumeration
            // object with our CarItemFilter RecordFilter
            // and a null RecordComparator which means
            // it will simply iterate the weapon records
            // in no particular order.  We're assuming, here,
            // that the Weapon records found won't need to be
            // in a certain sequence but can be rebuilt
            // willy-nilly.  You can always build your
            // own RecordComparator to put the enumeration into
            // some specific order.
            CarItemFilter filter = new CarItemFilter(WEAPON_RECORD);
            RecordEnumeration re = carDB.enumerateRecords(filter, null, false);

            // Prepare the necessary temp variables and
            int count = 0;
            int type = 0;
            int time = 0;
            int ammo = 0;
            String name = "";
            String description = "";
            while (re.hasNextElement())
            {
                // This next call returns the record's byte array and
                // advances the RecordEnumerator's pointer to the record
                // beyond the one returned.
                data = re.nextRecord();

                // Set up the streams...
                bin = new ByteArrayInputStream(data);
                din = new DataInputStream(bin);

                // Read and discard the weapon record id
                din.readByte();

                // Read the weapon type...
                type = din.readInt();

                // Read the weapon's ammo
                ammo = din.readInt();

                // Read the Weapon's time value
                time = din.readInt();
                
                // Read the Weapon's name 
                name = din.readUTF();
                System.out.println(count+") Got the Weapon name: "+name);

                // Read the Weapon's description
                description = din.readUTF();
                
                // Now rebuild the weapon into the
                // weapons array.
                weapons[count++] = new Weapon(type, time, ammo,name,description);

                // Clean up
                din.close();
                bin.close();
            }
        }
        catch (Exception e)
        {
            System.err.println("Exception in readStore()"+e);
		// This probably means we haven't created a store yet.
            try { carDB.closeRecordStore(); } catch (Exception e2) { }
            return false;
        }

        try { carDB.closeRecordStore(); } catch (Exception e2) { }
        System.out.println("Done Reading From Store");
        return true;
    }

    public int getCash() 
    {
        return cash;
    }

    public void setCash(int amount) 
    {
        cash = amount;
    }
    
    public Weapon[] getWeapons() 
    {
        return weapons;
    }

    public void setWeapons(Weapon[] w) 
    {
        weapons = w;
    }

}

// This class is the RecordFilter we'll use to
// find all the Weapon records.
class CarItemFilter implements RecordFilter
{
    // This will contain the car item id
    // we'll be looking for in the records.
    private byte filterValue;

    // Builds a new CarItemFilter for the
    // specific car record id we want to
    // find
    public CarItemFilter(int filterInt)
    {
        filterValue = (byte)filterInt;
    }

    // This is the RecordFilter method used
    // by the RecordEnumeration to determine
    // if the record is a "match" and needs
    // to be included in its enumeration.
    public boolean matches(byte[] candidate)
    {
        if (candidate == null || candidate.length == 0)
        {
            return false;
        }
        // Since, in the CarStore.writeToStore() method,
        // we wrote the item type byte to the records
        // before anything else, the byte at index 0
        // should be our id to filter.
        return (candidate[0] == filterValue);

    }

}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品国产精品国产专区不片| 色综合网色综合| 香蕉加勒比综合久久| 国产精品免费丝袜| 国产精品久久久久久妇女6080| 国产网站一区二区三区| 久久精品人人做| 亚洲国产精品激情在线观看| 国产亚洲成aⅴ人片在线观看| 国产欧美精品一区二区色综合 | 日韩午夜电影av| 欧美日韩精品系列| 欧美精品久久久久久久多人混战| 欧美性猛交一区二区三区精品 | 欧美精品色综合| 91精品国产91热久久久做人人 | 国产99久久久国产精品免费看 | 日韩国产精品久久久| 三级欧美在线一区| 美腿丝袜亚洲三区| 国内精品国产三级国产a久久| 国产丶欧美丶日本不卡视频| 99精品欧美一区二区蜜桃免费 | 成人在线一区二区三区| 成人性生交大片免费看中文网站| 91香蕉国产在线观看软件| 色噜噜夜夜夜综合网| 欧美美女bb生活片| 久久综合五月天婷婷伊人| 国产欧美日韩麻豆91| 亚洲精品国产精品乱码不99| 日韩影院免费视频| 国产精品一区二区在线观看不卡| caoporm超碰国产精品| 91精品91久久久中77777| 欧美一区二区日韩| 日本一区二区免费在线| 亚洲成a天堂v人片| 国产成人自拍高清视频在线免费播放| aaa欧美色吧激情视频| 欧美日韩大陆在线| 欧美国产欧美综合| 天天综合天天综合色| 东方aⅴ免费观看久久av| 欧美视频一区在线观看| 久久精品水蜜桃av综合天堂| 亚洲图片自拍偷拍| 国产91富婆露脸刺激对白| 欧美日韩一级片在线观看| 精品久久久久久久久久久久包黑料 | 国产大片一区二区| 欧美天堂一区二区三区| 国产日韩精品一区| 青青青伊人色综合久久| 色网综合在线观看| 日本一区二区在线不卡| 日韩精品欧美精品| 日本黄色一区二区| 国产精品色呦呦| 国产综合色精品一区二区三区| 欧美日韩国产成人在线免费| 中文字幕日韩欧美一区二区三区| 毛片av一区二区三区| 91黄色免费看| 一区在线中文字幕| 懂色av中文字幕一区二区三区| 精品国产一区二区国模嫣然| 美女尤物国产一区| 欧美三级电影在线观看| 亚洲免费av在线| 91免费观看国产| 国产精品免费视频观看| 国产成人精品免费看| 久久精品人人爽人人爽| 精品一区二区三区蜜桃| 日韩欧美一区二区三区在线| 奇米影视一区二区三区小说| 日韩一区二区三区av| 日韩福利视频导航| 欧美放荡的少妇| 久久精品国产亚洲一区二区三区| 9191成人精品久久| 蜜臀av亚洲一区中文字幕| 91精品国产色综合久久| 日韩电影免费在线看| 91精品国产91久久久久久一区二区| 日韩国产欧美在线视频| 日韩一区二区视频| 国内外成人在线视频| 久久久久久影视| 国产mv日韩mv欧美| 最新高清无码专区| 欧美性猛交一区二区三区精品| 日韩精品91亚洲二区在线观看| 欧美一区二区性放荡片| 精品一区二区三区免费| 中文字幕第一区二区| 91在线免费播放| 五月天丁香久久| 精品国产伦理网| eeuss鲁一区二区三区| 一区二区在线免费观看| 91.com视频| 成人激情开心网| 亚洲最大的成人av| 日韩免费高清视频| 不卡一区在线观看| 亚洲一区二区高清| 久久色视频免费观看| 94-欧美-setu| 免费观看久久久4p| 国产精品免费观看视频| 欧美视频一区在线观看| 国产河南妇女毛片精品久久久| 亚洲欧美日韩国产综合| 日韩欧美亚洲国产精品字幕久久久| 成人美女在线视频| 日韩电影一二三区| 综合激情网...| 久久中文娱乐网| 欧美午夜电影一区| 成人性生交大合| 久久精品久久精品| 亚洲精品中文在线| 2014亚洲片线观看视频免费| 欧美日韩精品一区二区天天拍小说| 国产成人在线视频网址| 日本色综合中文字幕| 一区视频在线播放| 久久久久九九视频| 3d成人h动漫网站入口| 91亚洲精品乱码久久久久久蜜桃| 老司机精品视频导航| 亚洲午夜久久久久久久久电影院 | 国产精品麻豆99久久久久久| 337p亚洲精品色噜噜| 97se亚洲国产综合在线| 国产精品自拍一区| 免费不卡在线视频| 亚洲欧洲成人自拍| 欧美网站一区二区| 风间由美性色一区二区三区| 久久99热这里只有精品| 亚洲免费大片在线观看| 国产精品超碰97尤物18| 国产网站一区二区三区| 7777精品伊人久久久大香线蕉完整版 | 国产婷婷色一区二区三区| 欧美日韩三级一区| 色婷婷精品久久二区二区蜜臀av| 国产精品99久| 激情六月婷婷久久| 亚洲乱码中文字幕综合| 欧美一级日韩一级| 欧美日韩美少妇| 欧美日韩久久久一区| 一本色道a无线码一区v| 99久久婷婷国产精品综合| 国产白丝网站精品污在线入口| 激情六月婷婷久久| 久久丁香综合五月国产三级网站| 日韩va亚洲va欧美va久久| 欧美国产亚洲另类动漫| 337p粉嫩大胆色噜噜噜噜亚洲| 日韩午夜精品视频| 欧美疯狂做受xxxx富婆| 日韩一区二区三区电影在线观看| 欧美一级国产精品| 精品日韩一区二区| 2023国产精华国产精品| 久久久久久久久一| 日韩欧美在线网站| 欧美另类一区二区三区| 3751色影院一区二区三区| 欧美一区日韩一区| 精品国产欧美一区二区| 久久嫩草精品久久久久| 国产精品婷婷午夜在线观看| 国产视频一区在线播放| 欧美丰满少妇xxxxx高潮对白| 色诱亚洲精品久久久久久| 成人精品高清在线| 一本一道久久a久久精品 | 亚洲国产wwwccc36天堂| 日韩中文欧美在线| 韩国成人福利片在线播放| 风间由美中文字幕在线看视频国产欧美 | 欧美三级蜜桃2在线观看| 欧美日高清视频| 久久综合av免费| 亚洲一区成人在线| 老司机免费视频一区二区 | 亚洲另类在线一区| 免费一区二区视频| 国产黄色成人av| 欧美日韩三级在线| 久久久蜜桃精品| 亚洲r级在线视频| 国产91清纯白嫩初高中在线观看| 欧美日本韩国一区二区三区视频|