-
Notifications
You must be signed in to change notification settings - Fork 1.7k
i have done #1913
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
base: master
Are you sure you want to change the base?
i have done #1913
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,19 +1,53 @@ | ||
| package core.basesyntax.impl; | ||
|
|
||
| import java.util.Objects; | ||
|
|
||
| import core.basesyntax.Storage; | ||
|
|
||
| public class StorageImpl<K, V> implements Storage<K, V> { | ||
|
|
||
| private final int MAX = 10; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. MAX is declared as instance field instead of static constant. Should be 'private static final int MAX_STORAGE_CAPACITY = 10;' |
||
|
|
||
| Object[] keys = new Object[MAX]; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Non-constant field 'keys' is initialized as field declaration. Per checklist: all non-constant fields should be initialized in the constructor. |
||
| Object[] values = new Object[MAX]; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Non-constant field 'values' is initialized as field declaration. Per checklist: all non-constant fields should be initialized in the constructor. |
||
| int size = 0; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Non-constant field 'size' is initialized as field declaration. Per checklist: all non-constant fields should be initialized in the constructor. |
||
|
|
||
| @Override | ||
| public void put(K key, V value) { | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Empty line at start of method implementation - remove redundant empty line. |
||
| for (int i = 0; i < size; i++) { | ||
|
|
||
| if (Objects.equals(keys[i], key)) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replaces existing key's value - uses Objects.equals which is not allowed per checklist requirements. |
||
|
|
||
| values[i] = value; | ||
| return; | ||
| } | ||
| } | ||
|
|
||
| keys[size] = key; | ||
| values[size] = value; | ||
|
|
||
| size++; | ||
|
|
||
| } | ||
|
|
||
| @Override | ||
| public V get(K key) { | ||
|
Comment on lines
35
to
36
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Empty line at start of method implementation - remove redundant empty line. |
||
|
|
||
| for (int i = 0; i < size; i++) { | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replaces existing key's value - uses Objects.equals which is not allowed per checklist requirements. |
||
| if (Objects.equals(keys[i], key)) { | ||
|
|
||
| return (V) values[i]; | ||
| } | ||
|
|
||
| } | ||
| return null; | ||
|
|
||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Empty line at start of method implementation - remove redundant empty line. |
||
|
|
||
| @Override | ||
| public int size() { | ||
| return -1; | ||
| return size; | ||
| } | ||
| } | ||
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.
Uses java.util.Objects class which violates 'Don't use class Objects' requirement. Replace Objects.equals() with a manual null-safe comparison method.