首先,我很抱歉问题的冗长,我不确定如何提问,但我可以更好地解释。
我有一个父类和两个子类,只有一个是示例
的相关性public abstract class AudioFile{ //parent
blah blah blah
} //end class AudioFile
public class MP3File extends AudioFile{
private int bitRate; //unique to MP3File class
} //end class MP3File
现在说我有一个MP3File对象,但它引用了AudioFile
public class Driver{
... // pretend main exists
AudioFile file = new MP3File();
file.setBitRate(100); //pretend method exists
edit(file);
private void edit(AudioFile audio)
{
//how would I edit the bit rate?
} //end method edit
} //end class Driver