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

📄 database.java

📁 感谢网站提供的资源
💻 JAVA
字号:
// FrontEnd Plus GUI for JAD
// DeCompiled : Database.class

import javax.microedition.rms.RecordStore;
import javax.microedition.rms.RecordStoreException;

public class Database
{

    private final int VIBRATION = 1;
    private final int SOUND = 2;
    private final int LIVELLO = 3;
    private final int PUNTEGGIO = 4;
    private final byte valori[] = {
        70, 86, 70, 78, 68
    };
    private RecordStore rs;

    Database()
    {
        rs = null;
    }

    private void openRecordStore()
        throws RecordStoreException
    {
        if(rs == null)
            rs = RecordStore.openRecordStore("Opzioni", true);
        if(rs.getNumRecords() == 0)
        {
            byte b[] = {
                86
            };
            rs.addRecord(b, 0, 1);
            rs.addRecord(b, 0, 1);
            byte c[] = {
                70
            };
            rs.addRecord(c, 0, 1);
            String pp = "0.0.0";
            rs.addRecord(pp.getBytes(), 0, pp.length());
            rs.addRecord(pp.getBytes(), 0, pp.length());
            rs.addRecord(pp.getBytes(), 0, pp.length());
        }
    }

    private void closeRecordStore()
        throws RecordStoreException
    {
        if(rs != null)
        {
            rs.closeRecordStore();
            rs = null;
        }
    }

    boolean getUseVibration()
    {
        try
        {
            return getValue(1) == 86;
        }
        catch(Exception e)
        {
            return false;
        }
    }

    boolean getUseSound()
    {
        try
        {
            return getValue(2) == 86;
        }
        catch(Exception e)
        {
            return false;
        }
    }

    short leggiLivello()
    {
        try
        {
            byte v = getValue(3);
            if(v == 70)
                return 0;
           
            if(v != 78) return 2; else return 1;
            
            
        }
        catch(Exception e)
        {
            return 0;
        }
    }

    String leggiPunteggio(int l)
        throws RecordStoreException
    {
        openRecordStore();
        byte bytes[] = rs.getRecord(4 + l);
        closeRecordStore();
        return new String(bytes);
    }

    void setUseVibration(boolean bool)
    {
        int v = 0;
        if(bool)
            v = 1;
        try
        {
            setValue(1, valori[v]);
        }
        catch(Exception e) { }
    }

    void setUseSound(boolean bool)
    {
        int v = 0;
        if(bool)
            v = 1;
        try
        {
            setValue(2, valori[v]);
        }
        catch(Exception e) { }
    }

    void assegnaLivello(int livello)
    {
        try
        {
            setValue(3, valori[livello + 2]);
        }
        catch(Exception e) { }
    }

    void assegnaPunteggio(int l, String punteggio)
        throws RecordStoreException
    {
        openRecordStore();
        rs.setRecord(4 + l, punteggio.getBytes(), 0, punteggio.length());
        closeRecordStore();
    }

    private void setValue(int id, byte b)
        throws RecordStoreException
    {
        byte ba[] = new byte[1];
        ba[0] = b;
        openRecordStore();
        rs.setRecord(id, ba, 0, 1);
        closeRecordStore();
    }

    private byte getValue(int id)
        throws RecordStoreException
    {
        openRecordStore();
        byte barray[] = rs.getRecord(id);
        closeRecordStore();
        return barray[0];
    }
}

⌨️ 快捷键说明

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