Skip to content
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

Open
wants to merge 231 commits into
base: feedback
Choose a base branch
from
Open

Feedback #1

wants to merge 231 commits into from

Conversation

github-classroom[bot]
Copy link
Contributor

@github-classroom github-classroom bot commented Mar 20, 2023

👋! 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:

  • Click the Files changed tab to see all of the changes pushed to 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”.
  • Click the Commits tab to see the commits pushed to main. Click a commit to see specific changes.
  • If you turned on autograding, then click the Checks tab to see the results.
  • This page is an overview. It shows commits, line comments, and general comments. You can leave a general comment below.
    For more information about this pull request, read “Leaving assignment feedback in GitHub”.

Subscribed: @Artem-Rzhankoff @ItIsMrLaG @RozhkovAleksandr

github-classroom bot and others added 30 commits March 20, 2023 10:49
…eeStructs in tests; Create template for TreeStruct tests
…n values of abstract methods: insertItem, deleteItem, findItem
Copy link

@sofurihafe sofurihafe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Comment on lines 104 to 111
private fun isInt(value: String): Boolean {
return try {
Integer.parseInt(value.trim())
true
} catch (ex: NumberFormatException) {
false
}
}

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.

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()

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()

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>>> {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {

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.

Comment on lines +46 to +45
if (childForLink != null) {
childForLink.parent = parent
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (childForLink != null) {
childForLink.parent = parent
}
childForLink?.parent = parent

}
} else root?.let {
root = childForLink
if (childForLink != null) childForLink.parent = null

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (childForLink != null) childForLink.parent = null
childForLink?.parent = null

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants