-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feedback #1
base: feedback
Are you sure you want to change the base?
Feedback #1
Conversation
…ts to the code style
…baseNode and unLink in TreeStruct
…eeStructs in tests; Create template for TreeStruct tests
…n values of abstract methods: insertItem, deleteItem, findItem
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
private fun isInt(value: String): Boolean { | ||
return try { | ||
Integer.parseInt(value.trim()) | ||
true | ||
} catch (ex: NumberFormatException) { | ||
false | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the following looks better. Don't forget to fix usages.
private fun isInt(value: String): Boolean { | |
return try { | |
Integer.parseInt(value.trim()) | |
true | |
} catch (ex: NumberFormatException) { | |
false | |
} | |
} | |
private fun String.presentAsKey(): Int { | |
return this.trim().toIntOrNull() ?: this.hashCode() | |
} |
} | ||
|
||
fun delete(value: String): DrawTree { | ||
val key = if (isInt(value.trim())) value.toInt() else value.hashCode() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Funny looking thing :).
|
||
tree?.initTree() | ||
|
||
return tree ?: throw NullPointerException() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are myriads of throws everywhere, which looks scary tbh. As I see, you don't catch and process them later, so I don't get the idea of throwing that much...
For a better look you could use
requireNotNull(tree) { message }
at the beginning of the methods.
db.initDataBase(AVL_DB_DEFAULT_NAME) | ||
} | ||
|
||
private fun drawVertexToVertex(drawVertex: MutableList<DrawableAVLVertex<Container<Int, String>>>): MutableList<AVLVertex<Container<Int, String>>> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looong line.
private fun drawVertexToVertex(drawVertex: MutableList<DrawableAVLVertex<Container<Int, String>>>): MutableList<AVLVertex<Container<Int, String>>> { | |
private fun drawVertexToVertex( | |
drawVertex: MutableList<DrawableAVLVertex<Container<Int, String>>> | |
): MutableList<AVLVertex<Container<Int, String>>> { |
|
||
} | ||
|
||
fun createTree(treeName: String, id: Int): DrawTree { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Public methods go first, private methods go second.
if (childForLink != null) { | ||
childForLink.parent = parent | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (childForLink != null) { | |
childForLink.parent = parent | |
} | |
childForLink?.parent = parent |
} | ||
} else root?.let { | ||
root = childForLink | ||
if (childForLink != null) childForLink.parent = null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (childForLink != null) childForLink.parent = null | |
childForLink?.parent = null |
lib/src/main/kotlin/viewPart/nodes/drawableTree/DrawableTree.kt
Outdated
Show resolved
Hide resolved
…o art # Conflicts: # lib/src/main/kotlin/ui/ControlFields.kt # lib/src/main/kotlin/viewPart/nodes/TreeDrawingUtils.kt
Application implement
Refactor project structure #32
👋! GitHub Classroom created this pull request as a place for your teacher to leave feedback on your work. It will update automatically. Don’t close or merge this pull request, unless you’re instructed to do so by your teacher.
In this pull request, your teacher can leave comments and feedback on your code. Click the Subscribe button to be notified if that happens.
Click the Files changed or Commits tab to see all of the changes pushed to
main
since the assignment started. Your teacher can see this too.Notes for teachers
Use this PR to leave feedback. Here are some tips:
main
since the assignment started. To leave comments on specific lines of code, put your cursor over a line of code and click the blue + (plus sign). To learn more about comments, read “Commenting on a pull request”.main
. Click a commit to see specific changes.For more information about this pull request, read “Leaving assignment feedback in GitHub”.
Subscribed: @Artem-Rzhankoff @ItIsMrLaG @RozhkovAleksandr