Skip to content
Snippets Groups Projects
Commit 87f3409b authored by s2010720's avatar s2010720
Browse files

Add fault tree structure based on Jarik's AttackTree

parent 4ce6d8f3
No related branches found
No related tags found
No related merge requests found
package FaultTree;
import java.util.ArrayList;
public class BasicEvent implements FaultTree {
public int ID;
public String name;
public int order;
private ArrayList<IntermediateEvent> parents;
public BasicEvent(int ID, String name, int order) {
this.ID = ID;
this.name = name;
this.order = order;
this.parents = new ArrayList<>();
}
/**
* Get name of the Leaf
* @return name of the leaf
*/
public String getName() {
return "\"" + name + "-" + ID + "\"";
}
/**
* Get ID of the Leaf
* @return ID of the Leaf
*/
public int getID() {
return ID;
}
/**
* Get unique name for the Leaf
* @return unique name for the Leaf
*/
public String getUniqueName() {
return "\"" + name + "-" + ID + "\"";
}
/**
* Add parent to the Leaf.
* @param parent parent of the leaf
*/
public void addParent(IntermediateEvent parent) {
this.parents.add(parent);
}
/**
* Get parents of the Leaf
* @return parents of th eLeaf
*/
public ArrayList<IntermediateEvent> getParents() {
return parents;
}
public int getOrder() {
return order;
}
public void setOrder(int order) {
this.order = order;
}
/**
* Create a copy of the Leaf
* @return copy of the Leaf
*/
public FaultTree copy() {
return new BasicEvent(ID, name, order);
}
}
package FaultTree;
import java.util.ArrayList;
public interface FaultTree {
int getID();
String getName();
String getUniqueName();
void addParent(IntermediateEvent parent);
ArrayList<IntermediateEvent> getParents();
FaultTree copy();
}
package FaultTree;
import java.util.ArrayList;
public class IntermediateEvent implements FaultTree {
public int ID;
public Type type;
public String name;
public FaultTree left;
public FaultTree right;
private ArrayList<IntermediateEvent> parents;
public IntermediateEvent(int ID, String name, Type type, FaultTree left, FaultTree right) {
this.ID = ID;
this.name = name;
this.type = type;
this.left = left;
this.left.addParent(this);
this.right = right;
this.right.addParent(this);
this.parents = new ArrayList<>();
}
/**
* Get a name of the IntermediateEvent
* @return name of the IntermediateEvent
*/
public String getName() {
return "\"" + name + "-" + type + "\"";
}
/**
* Get a unique name for the IntermediateEvent including ID
* @return unique name of the IntermediateEvent
*/
public String getUniqueName() {
return "\"" + name + "-" + type + "-" + ID + "\"";
}
/**
* Get the ID of the IntermediateEvent
* @return ID of the IntermediateEvent
*/
public int getID() {
return ID;
}
/**
* Get parents of the IntermediateEvent
* @return list of parents of the IntermediateEvent
*/
public ArrayList<IntermediateEvent> getParents() {
return parents;
}
/**
* Add a parent to the IntermediateEvent. Used in construction.
* @param parent, parent to add
*/
public void addParent(IntermediateEvent parent) {
this.parents.add(parent);
}
/**
* Creates a copy of the IntermediateEvent
* @return copy of the IntermediateEvent
*/
public FaultTree copy() {
return new IntermediateEvent(ID, name, type, left.copy(), right.copy());
}
}
package FaultTree;
public enum Type {
Or,
And
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment