Conversation
# Conflicts: # src/main/java/school/lemon/changerequest/java/extendedinteger/ExtendedInteger.java
xSAVIKx
left a comment
There was a problem hiding this comment.
waiting for other tasks. Also pay attention on comments below.
| */ | ||
| public static boolean isEven(int value) { | ||
| //TODO: implement me | ||
| if ((value & 1) == 0) { |
There was a problem hiding this comment.
just return your expression, there is no need for if-else
There was a problem hiding this comment.
@IgorAfanasenko I don't see any changes checked in, have you already perform commit and pushed your changes ?
| */ | ||
| public static boolean isOdd(int value) { | ||
| //TODO: implement me | ||
| if ((value & 1) == 1) { |
| } | ||
| resultSum += result; | ||
| } | ||
| resultSum *= first; |
There was a problem hiding this comment.
You algorithm is OK, but implementation details sucks.
Try to create more valuable variable names, for example:
What do you mean with your first variable ? In fact, you need to check the sign of int value, if it's plus or minus and multiply result by 1 or -1 respectively. So, probably variable name sign will suite here better.
Additionally you've got j, k, i indexes, but you really need only one.
Also, there is no need for 2 variables for result you can reuse one.
But, anyway, you code do pass all the tests.
| //TODO: implement me | ||
| return null; | ||
|
|
||
| char[] newChar = value.toCharArray(); |
| if (obj == this) | ||
| return true; | ||
|
|
||
| if (obj == null) |
There was a problem hiding this comment.
null check should always be the first one, as there is nothing to do if obj==null.
| if (obj == null) | ||
| return false; | ||
|
|
||
| if (!(getClass() == obj.getClass())) |
There was a problem hiding this comment.
it's always better to avoid negation.
this part could be rewritten as: getClass() != obj.getClass()
|
|
||
| if (!(getClass() == obj.getClass())) | ||
| return false; | ||
| else { |
There was a problem hiding this comment.
there is no need for else statement here, cause you always use return
| return false; | ||
| else { | ||
| ExtendedInteger tmp = (ExtendedInteger) obj; | ||
| if (tmp.value == this.value) |
There was a problem hiding this comment.
you can just return result of this expression: return tmp.value == this.value
No description provided.