我有两个问题 - 我是 Java 初学者,但有一个庞大的 Java 项目 :(
如果我实现一个类(这是一个具有两个 void 方法的接口)并且我尝试在我的类中编写另一个方法,它会编译但在运行时该方法被跳过?我可能做错了什么?
我如何从另一个不是主要的类中运行一个类。所以基本上主运行一个类,然后调用另一个类......
我知道这些问题在内容方面非常有限,但程序真的很复杂,无法解释一切:(
任何帮助将不胜感激:) 谢谢!
--- 更新 - 根据要求
class FriendLists implements Results {
public void processCommunication (Communication d) {...}
public void postProcess() {...}
//the above two run perfectly
//I don't know what to do next.
//I'm trying to create a link to my other class, to use the values values
//but when compiled and running it skips this method (and all other methods except the above two
public void processCommunication(AggregatedDirect f) {
//does something from the class I'm trying to run
man = f.getNumTargets(); //getNumTargets is a value in the AggregatedDirect Class
}
,
interface Results {
void processCommunication (Communication c) throws SAXException;
void postProcess();
}
,
public class AggregatedDirect extends Communication {
ArrayList<Integer> targets;
public AggregatedDirect(Direct d) {
super();
targets = new ArrayList<Integer>();
this.type = d.getType();
this.invocSerial = d.getInvocSerial();
this.serial = d.getSerial();
this.usage = d.getUsage();
this.messageType = d.getMessageType();
this.characterID = d.getCharacterID();
this.characterStatus = d.getCharacterStatus();
this.locationID = d.getLocationID();
targets.add(d.getTargetCharacterID());
this.targetCharacterID = -1;
this.targetCharacterStatus = -1;
this.targetCharacterLocationID = -1;
this.message = d.getMessage();
this.time = d.getTime();
this.annotation = d.getAnnotation();
}
public void addTarget(int targetCharacterID) {
targets.add(targetCharacterID);
}
public void addTarget(Direct d){
addTarget(d.getTargetCharacterID());
}
public int getNumTargets() {
if (targets == null)
return -1;
else
return targets.size();
}
public ArrayList<Integer> getTargets() {
return targets;
}
}
- 在这里描述类
Communication
。 - 所有通信的抽象超类
- 子类。
实际上 - 处理 XML 文件并将其分离
- 直接扩展通信 // 它基本上是 XML 文件中的字符串值之一