Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added toString for printing display

  • Loading branch information...
commit 056eaaf309f118dc10ddce48c19af4ae59980e1e 1 parent 1735756
@leadVisionary authored
View
5 src/com/visionarysoftwaresolutions/menu/composite/MenuComponent.java
@@ -30,4 +30,9 @@ public void setText(String name){
public abstract MenuComponent getChild(String text);
public abstract MenuIterator createIterator();
+
+ @Override
+ public String toString(){
+ return getText();
+ }
}
View
14 src/com/visionarysoftwaresolutions/menu/composite/MenuComposite.java
@@ -40,4 +40,18 @@ public MenuComponent getChild(String text) {
public MenuIterator createIterator() {
return new MenuIterator(components.values());
}
+
+ @Override
+ public String toString(){
+ StringBuilder result = new StringBuilder();
+ result.append(super.toString());
+ result.append(" children - ");
+ MenuIterator it = createIterator();
+ while(it.hasNext()){
+ result.append(" ");
+ result.append(it.next().toString());
+ result.append(" ");
+ }
+ return result.toString();
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.