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

Student #1676

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Student #1676

wants to merge 2 commits into from

Conversation

OksanaEnko
Copy link

No description provided.

Copy link

@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.


Great job on implementing the StorageImpl class! 🎉 Your solution meets the task requirements and constraints effectively. The handling of key-value pairs and adherence to the constraints, such as using arrays and avoiding collections, is well-executed.

While your implementation is correct, consider the following suggestions for future improvements:

  • Capacity Handling: You've correctly ensured that the storage does not exceed its capacity. However, think about how you might handle scenarios when the capacity is reached, such as notifying the user or expanding the storage.
  • Null Key Handling: Your logic for handling null keys is sound, but ensure it aligns with the intended behavior. If null keys are not desired, consider adding a check to prevent them.

Keep up the great work, and continue refining your skills! 😊

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

@Override
public void put(K key, V value) {
for (int i = 0; i < size; i++) {
if ((keys[i] == null && key == null) || (keys[i] != null && keys[i].equals(key))) {

Choose a reason for hiding this comment

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

The condition (keys[i] == null && key == null) is used to handle null keys. Ensure that this logic is consistent with the intended behavior of the storage, especially if null keys are allowed. If null keys are not allowed, consider adding a check to prevent them from being added.

return;
}
}
if (size < MAX_CAPACITY) {

Choose a reason for hiding this comment

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

The check if (size < MAX_CAPACITY) ensures that the storage does not exceed its capacity. This is correct, but be aware that once the capacity is reached, no more entries can be added. Consider handling this scenario if needed.

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