English 中文(简体)
动物园区档案
原标题:Game Settings file prob

鉴于Im在环境负荷系统上工作,我不想工作,我尝试了不同的方式这样做,而除了不工作外,这看上去是最佳的,因为我需要在当天年底之前这样做。

该守则是:

public GameSettings getGameSettings() throws Exception
{
    Resolution GameResolution;
    GameSettings gs = new GameSettings(true, true, false, 50, new Resolution(800, 600));

    for(int k = 0; k < lines.size(); k++)
    {
        String[] s1 = lines.get(k).split("=");

        if(s1[0].equals("volume"))
        {
            gs.setVolume(Integer.parseInt(s1[1]));
        }
        if(s1[0].equals("musicOn"))
        {
            gs.setMusicOn(Boolean.parseBoolean(s1[1]));
        }
        if(s1[0].equals("soundOn"))
        {
            gs.setSoundOn(Boolean.parseBoolean(s1[1]));
        }
        if(s1[0].equals("aOpenGL"))
        {
            gs.setAOpenGL(Boolean.parseBoolean(s1[1]));
        }
        if(s1[0].equals("GameRes"))
        {
            String[] s2 = s1[1].split("x");
            GameResolution = new Resolution(Integer.parseInt(s2[1]), Integer.parseInt(s2[1]));
            gs.setGameResolution(GameResolution);
        }
        if(s1[0].startsWith("#"))
        {
            continue;
        }
        else
        {
            System.err.println("WARNING: Unknow setting in settings file ( " + s1[0] + " )");
            continue;
        }
    }

    return gs;
}

, this is the settings.dat file content:

#************************** Settings
#Settings file version 1.5
musicOn=false
volume=75
soundOn=true
aOpenGL=false
GameRes=1000x800
#end of settings file

并且最后是青春期产出:

WARNING: Unknow setting in settings file ( musicOn )
WARNING: Unknow setting in settings file ( volume )
WARNING: Unknow setting in settings file ( soundOn )
WARNING: Unknow setting in settings file ( aOpenGL )
WARNING: Unknow setting in settings file ( GameRes )
最佳回答

Apparently, in your code for any non-commented line you print a warning.

I guess you actually wanted to use else if instead of if every time, as in your code the final else refers to the if above only.

问题回答

您需要将<条码>查询/编码>与<条码>挂钩。

if (str.equals("a")) {
  ...
} else if (str.equals("b")) {
  ...
} else {
  // failed to match anything
}

页: 1 如果每当休息时间评估一次,那么 Unkown<>/code>的电文将显示所有不作评论的行文,而不论这些电文是否与原样。





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...