G
Guest
Gast
hallo, also ich hab folgendes code
ich sollte es in eine generische klasse umwandeln u. nach der umwandlung sollen Integer u. Data nichr mehr in BinaryTreeNode auftauchen. Alle Referenzen auf andere Knoten sollen dann Referenzen auf den generischen Knotentyp sein.
danke im voraus für Tipps
Code:
public class BinaryTreeNode implements BinaryNode<T> {
private Object data;
/** @return the data entry hold by the tree node */
public Object getData() {
return data;
}
private Integer key;
/** @return the key entry associated width the tree node */
public Integer getKey() {
return key;
}
private BinaryTreeNode parent = null;
/** @return the parent of the tree node. null if the node is the root of the tree*/
public BinaryTreeNode getParent() {
return parent;
}
/** sets the parent of the tree node.*/
public void setParent(BinaryTreeNode newParent) {
this.parent = newParent;
}
private BinaryTreeNode left = null;
/** @return the left child node of the tree node. null if there is no left child*/
public BinaryTreeNode getLeft() {
return left;
}
/** sets the left Child of the tree node.*/
public void setLeft(BinaryTreeNode newLeft) {
this.left = newLeft;
}
private BinaryTreeNode right = null;
/** @return the right child node of the tree node. null if there is no right child*/
public BinaryTreeNode getRight() {
return right;
}
/** sets the right Child of the tree node.*/
public void setRight(BinaryTreeNode newRight) {
this.right = newRight;
}
/** Basic Node Constructor.
* @param newKey the key who is used to find the position of the node in the tree.
* @param the data stored in the tree node.
*/
public BinaryTreeNode(Integer newKey, Object newData)
{
this.key = newKey;
this.data = newData;
}
@Override
public String toString(){
return this.key.toString() + ":" + this.data.toString();
}
}
ich sollte es in eine generische klasse umwandeln u. nach der umwandlung sollen Integer u. Data nichr mehr in BinaryTreeNode auftauchen. Alle Referenzen auf andere Knoten sollen dann Referenzen auf den generischen Knotentyp sein.
danke im voraus für Tipps