mirror of
https://github.com/AdrianKuta/Tree-Data-Structure.git
synced 2025-04-19 23:19:03 +02:00
Extracted prettyString from toString()
method to new method prettyString()
This commit is contained in:
parent
3f166aced0
commit
eb2d5f07be
@ -22,7 +22,7 @@ val poland = TreeNode("Poland")
|
||||
val france = TreeNode("France")
|
||||
europe.addChild(poland)
|
||||
europe.addChild(france)
|
||||
println(root)
|
||||
println(root.prettyString())
|
||||
```
|
||||
|
||||
**Pretty Kotlin**
|
||||
@ -55,7 +55,7 @@ TreeNode<String> poland = new TreeNode<>("Poland");
|
||||
TreeNode<String> france = new TreeNode<>("France");
|
||||
europe.addChild(poland);
|
||||
europe.addChild(france);
|
||||
System.out.println(root);
|
||||
System.out.println(root.prettyString());
|
||||
```
|
||||
|
||||
*Output:*
|
||||
|
@ -15,7 +15,7 @@ android {
|
||||
minSdkVersion 15
|
||||
targetSdkVersion 29
|
||||
versionCode 1
|
||||
versionName "1.2.0"
|
||||
versionName "1.2.1"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
consumerProguardFiles 'consumer-rules.pro'
|
||||
|
@ -91,6 +91,10 @@ open class TreeNode<T>(val value: T) : Iterable<TreeNode<T>>, ChildDeclarationIn
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
return value.toString()
|
||||
}
|
||||
|
||||
fun prettyString(): String {
|
||||
val stringBuilder = StringBuilder()
|
||||
print(stringBuilder, "", "")
|
||||
return stringBuilder.toString()
|
||||
|
Loading…
x
Reference in New Issue
Block a user