Skip to content

complete task#1907

Open
OlenaShtronda wants to merge 1 commit into
mate-academy:masterfrom
OlenaShtronda:master
Open

complete task#1907
OlenaShtronda wants to merge 1 commit into
mate-academy:masterfrom
OlenaShtronda:master

Conversation

@OlenaShtronda
Copy link
Copy Markdown

No description provided.

Copy link
Copy Markdown

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

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

Review Summary

Your solution is approved because it correctly implements a generic key–value storage with put, get, and size using two arrays, with MAX_SIZE = 10, and it properly replaces values when a key is re‑used. The use of a private helper (like findKeyIndex) keeps the code DRY, and your handling of null keys and generic typing is consistent and clear. All core requirements are met: arrays are initialized in the constructor, there are no forbidden collections or Objects usage, and size() accurately reflects the number of stored entries.

One minor improvement area: in your put method, when you add a new key with something like keys[size] = key; values[size] = value; size++;, there is no explicit guard to prevent writing beyond the array when more than 10 distinct keys are inserted, which would lead to an ArrayIndexOutOfBoundsException. Given the task’s constraint of a maximum of 10 elements, this is acceptable for the current requirements, but you could defensively check if (size < MAX_SIZE) before inserting and decide how to handle the “full storage” case (e.g., ignore the new pair or overwrite some entry). Overall, your implementation is clean, readable, and functionally correct for the specified constraints—well done.


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Footnotes

  1. Rate AI review example

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.

2 participants