Open
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
sofurihafe
reviewed
May 2, 2023
Comment on lines
104
to
111
| private fun isInt(value: String): Boolean { | ||
| return try { | ||
| Integer.parseInt(value.trim()) | ||
| true | ||
| } catch (ex: NumberFormatException) { | ||
| false | ||
| } | ||
| } |
There was a problem hiding this comment.
I think the following looks better. Don't forget to fix usages.
Suggested change
| 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() |
|
|
||
| tree?.initTree() | ||
|
|
||
| return tree ?: throw NullPointerException() |
There was a problem hiding this comment.
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.
Looong line.
Suggested change
| 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.
Public methods go first, private methods go second.
Comment on lines
+46
to
+45
| if (childForLink != null) { | ||
| childForLink.parent = parent | ||
| } |
There was a problem hiding this comment.
Suggested change
| 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.
Suggested change
| 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
👋! 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
mainsince the assignment started. Your teacher can see this too.Notes for teachers
Use this PR to leave feedback. Here are some tips:
mainsince 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