Slick2D 게임을 만들고 있습니다. 지금은 내부 클래스 (FrameSize, FPS, FullScreen ..)가 포함 된 Video 클래스를 만들고 있습니다. 그래서 저는 우리가 System.out.println()을 호출하는 것과 같은 방법으로 상자에 넣으려는 OOD 아이디어를 가지고있었습니다. 즉, 공개 Video 클래스와 내부 정적 클래스의 정적 정적 인스턴스를 갖지만 Netbeans IDE는 "공개 API를 통해 비공개 유형 내보내기"라는 힌트를 던졌습니다. 그래서, 나는 그것을 무시하고 내가하고 있었던 방식대로 계속해야합니까, 아니면 나에게 당신의 아이디어를 제안 할 수 있다면 좋을까요?Netbeans 경고 : 공용 API를 통해 비공개 형식 내보내기
VIDEO
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;
}
}
}
AUDIO
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;
}
}
}
나는 알고 있습니다. 나는 그것에 대해 몰랐다. 그러나, 두 번째 질문이었던 다른 생각을 나에게 제안 할 수 있겠는가? 권장하지 않기 때문에 다른 패키지에서이 클래스를 확실히 사용할 것이므로 정적 클래스로 내부 클래스를 만들어야 할까? – nellykvist
OH 대기,이 경고는 내부 클래스에 적용됩니까? 위의 비디오 클래스 외부의 개인 클래스에 대한 예제가 나와 있기 때문에이 경고가 적용됩니까? – nellykvist
글쎄, 그냥 VideoSite 클래스의 중첩 된 클래스로 FramSize 테스트하고 공개로 설정,이 올바른 방법이 무엇입니까? – nellykvist