gpt4 book ai didi

java - Netbeans 警告 : Exporting non-public type through public API

转载 作者:塔克拉玛干 更新时间:2023-11-03 04:12:01 25 4
gpt4 key购买 nike

<分区>

我正在创建一个 Slick2D 游戏。现在,我正在创建一个 Video 类,其中包含内部类(FrameSize、FPS、FullScreen..)。所以我有一个 OOD 想法以一种方式进行包装,就像我们调用 System.out.println() 一样。这意味着我将拥有他的内部类的公共(public)视频类和公共(public)静态实例,但是 netbeans IDE 向我提示“通过公共(public) API 导出非公共(public)类型”。那么,我是应该忽略它并继续按照我的方式做,还是如果你能向我提出你的想法就太好了?

视频

public class Video {

public static FrameSize frameSize;
public static FullScreen fullScreen;
public static FPS fps;

private Video() {}

public static void loadArguments(Scanner loadInput) {
boolean isVideo = false;
String readLine;

while (loadInput.hasNext()) {
readLine = loadInput.next();
if (readLine.equalsIgnoreCase("video")) {
isVideo = true;
break;
}
}

while (isVideo && loadInput.hasNext()) {
readLine = loadInput.next();
if (readLine.equalsIgnoreCase("end")) {
break;
}
String[] line = readLine.split("=");

String key = line[0];
String value = line[1];

switch (key) {
case "width":
frameSize.setWidth(Integer.parseInt(value));
break;
case "height":
frameSize.setHeight(Integer.parseInt(value));
break;
case "fullscreen":
break;
case "fps":
break;
default:
System.err.println("Unknown video key: " + key);
break;
}
}
}

public static void saveArguments(String filePath) {
Scanner saveInput;
try {
saveInput = new Scanner(new File(filePath));
} catch (FileNotFoundException fne) {
System.err.println("Invalid settings-file.");
return;
}

// TO DO: save function

saveInput.close();
}

class FrameSize {

public final int[][] SIZE_VALUES = {
{800, 600},
{1000, 700},
{1200, 800},
{1400, 900}
};

private int index;
private int width, height;

private FrameSize() {}

public void setSize(int width, int height) {
this.width = width;
}

public int getWidth() {
return width;
}

public void setWidth(int width) {
this.width = width;
}

public int getHeight() {
return height;
}

public void setHeight(int height) {
this.height = height;
}

@Override
public String toString() {
return this.width + " x " + this.height;
}

}

class FullScreen {

private boolean fullScreen;

private FullScreen() {}

public boolean isFullScreen() {
return fullScreen;
}

public void setFullScreen(boolean fullScreen) {
this.fullScreen = fullScreen;
}

@Override
public String toString() {
return "" + fullScreen;
}
}

class FPS {

private boolean FPS;

private FPS() {}

public boolean isFPS() {
return FPS;
}

public void setFPS(boolean FPS) {
this.FPS = FPS;
}

@Override
public String toString() {
return "" + fps;
}

}

}

音频

public class Audio {

private static Sound sound;
private static Volume volume;

private Audio() {}

public void loadArguments(Scanner loadInput) {
boolean isAudio = false;
String readLine;

while (loadInput.hasNext()) {
readLine = loadInput.next();
if (readLine.equalsIgnoreCase("audio")) {
isAudio = true;
break;
}
}

while (isAudio && loadInput.hasNext()) {
readLine = loadInput.next();
if (readLine.equalsIgnoreCase("end")) {
break;
}
String[] line = readLine.split("=");

String key = line[0];
String value = line[1];

switch (key) {
case "sound":
break;
case "volume":
break;
default:
System.err.println("Unknown audio key: " + key);
break;
}
}
}

public void saveArguments(String filePath) {
Scanner saveInput;
try {
saveInput = new Scanner(new File(filePath));
} catch (FileNotFoundException fne) {
System.err.println("Invalid settings-file.");
return;
}

// TO DO: save function

saveInput.close();
}

class Sound {

private boolean sound;

private Sound() {}

public boolean isSound() {
return sound;
}

public void setSound(boolean sound) {
this.sound = sound;
}

@Override
public String toString() {
return "" + sound;
}
}

class Volume {

private static final double PITCH = 0.1d;
private double volume;

private Volume() {}

public double getVolume() {
return volume;
}

public void setVolume(double volume) {
this.volume = volume;
}

public void increaseVolume() {
if (!isVolumeRange(this.volume)) {
return;
}
this.volume = this.volume + PITCH;
}

public void decreaseVolume() {
if (!isVolumeRange(this.volume)) {
return;
}
this.volume = this.volume - PITCH;
}

public boolean isVolumeRange(double volume) {
return volume >= 0.0 && volume <= 10.0;
}

}

}

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com