From charlesreid1

No edit summary
(Redirected page to Java/Abstract Class)
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
Example: defining an abstract Tree type that implements abstract methods for some of the methods required by the Tree ADT:
#REDIRECT [[Java/Abstract Class]]
* element()
* root()
* is_root
* parent
* num_children
* is_leaf
 
<pre>
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
}
</pre>
 
 
 
[[Category:Java]]
[[Category:OOP]]
[[Category:Data Structures]]

Latest revision as of 19:49, 18 June 2017