From charlesreid1

No edit summary
No edit summary
Line 22: Line 22:




Java API Docs tutorial: [https://docs.oracle.com/javase/tutorial/java/IandI/abstract.html link]


[[Category:Java]]
[[Category:Java]]
[[Category:OOP]]
[[Category:OOP]]
[[Category:Data Structures]]
[[Category:Data Structures]]

Revision as of 00:17, 7 June 2017

Example: defining an abstract Tree type that implements abstract methods for some of the methods required by the Tree ADT:

  • element()
  • root()
  • is_root
  • parent
  • num_children
  • is_leaf
public abstract class Tree {
   abstract Node root();
  abstract Node parent(Node n);
  abstract int num_children(Node n);
  abstract Node children(Node n);
  abstract boolean is_leaf(Node n);
  abstract int length();
  abstract boolean isEmpty();
  // positions() - iteration of all Nodes in the tree
  // iter() - iteration of all elements in the tree
}



Java API Docs tutorial: link