Conversation
| } | ||
| } | ||
|
|
||
| private void readFromConsole() throws Exception { |
There was a problem hiding this comment.
SonarLint: Using such generic exceptions as Error, RuntimeException, Throwable, and Exception prevents calling methods from handling true, system-generated exceptions differently than application-generated errors.
| String outputString = "x"; | ||
| for (int i = 0; i < inputInt; i++) { | ||
| joiner.add(outputString); | ||
| outputString = outputString + "x"; |
There was a problem hiding this comment.
check StringBuilder class
| public class Main { | ||
|
|
||
| public static void main(String[] args) { | ||
| new Game().run(); |
There was a problem hiding this comment.
Good! The game works fine, even though it's not really comfortable to play. I didn't find any bugs, and you show good knowledge and skills using Java Core and Java libraries, Java 8 features as well.
To make better: refactor interface (automatic ship placement, field representation to more comfortable. You chose the easiest approach where fields representation is the same for both players, it could be improved.)
Also, here and there I can see typos and Code Conventions violations in minor things. Not critical, but disturbing.
|
|
||
| import java.util.Arrays; | ||
|
|
||
| public final class ImmutableTask { |
|
|
||
| public class Main { | ||
|
|
||
| public static void main(String[] args) { |
| import java.util.Scanner; | ||
| import java.util.stream.Collectors; | ||
|
|
||
| public class CustomFileReader { |
| import java.util.UUID; | ||
|
|
||
| //has serialization and thread-safety guaranteed by the enum implementation itself | ||
| public enum EnumDatabaseConnection { |
There was a problem hiding this comment.
Nice example, a good understanding of Java concepts and inner implementation!
|
|
||
| public class CustomRegexMatcher { | ||
|
|
||
| final private String regex_email = "^[^0-9]\\w+@[^0-9]\\w+(\\.[a-z]{2,3}){1,2}$"; |
There was a problem hiding this comment.
Nice regex and description
| import java.io.InputStreamReader; | ||
| import java.math.BigInteger; | ||
|
|
||
| public class PowerOfNumber { |
There was a problem hiding this comment.
Not a common implementation of recursion, it can be confusing. Well, works anyway
|
|
||
| public class MapProblemsCollisionGenerator { | ||
|
|
||
| public static void main(String[] args) { |
There was a problem hiding this comment.
Good example of mutable key problem, but where's the object, that makes 100% collisions in hashMap?
|
|
||
| public class Main { | ||
|
|
||
| public static void main(String[] args) { |
There was a problem hiding this comment.
Opt: you could introduce such fields and such lambda, that it will make type conversion as well (as example, weight to size or smth like this)
| ImmutableTask task = new ImmutableTask("Immutable class"); | ||
|
|
||
| ImmutableTask taskAfterChangeName = task.changeName("new name here!!!"); | ||
| assertNotEquals(task, taskAfterChangeName); |
There was a problem hiding this comment.
Opt: Two objects can be equal, but not the same, right? I mean criteria of equality, when we check mutability, might be prone to errors
| //Class singleton | ||
| assertEquals(DatabaseConnection.getInstance("superAdmin"), DatabaseConnection.getInstance("admin")); | ||
| //Enum singleton | ||
| assertEquals(EnumDatabaseConnection.INSTANCE.getInstance(), EnumDatabaseConnection.INSTANCE.getInstance()); |
There was a problem hiding this comment.
Opt: equals is not the same, right?
|
|
||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
|
||
| class PowerOfNumberTest extends UnitBase { |
NikolaevArtem
left a comment
There was a problem hiding this comment.
Well-done! I approve the HW, but you also need to add fixes to HW_6. You show good knowledge of Java Core, complicated Java concepts and use them where needed, without making the code complicated, it's cool. I would suggest checking your code for typos/unused imports/etc, even though this does not affect implementation, it can cause smelly code in general and lead to bugs later.
No description provided.