Conversation
|
Homework_2 done. |
…ture/KrylosovArkady # Conflicts: # src/main/java/homework_2/randomCharsTable/Strategy.java
…ture/KrylosovArkady
README.md
Outdated
| | --- | --- | --- | | ||
| | HW1 | [Console printer](https://github.com/NikolaevArtem/Java_Core_June_2021/tree/master/src/main/java/homework_1) | The app that reads input arguments and prints them, until "error" argument | | ||
| | HW1 | [Console printer](https://github.com/NikolaevArtem/Java_Core_June_2021/tree/feature/KrylosovArkady/src/main/java/homework_1) | The app that reads input arguments and prints them, until "error" argument | | ||
| | HW2.1 | [Traffic Light](https://github.com/NikolaevArtem/Java_Core_June_2021/tree/feature/KrylosovArkady/src/main/java/homework_2/trafficLight) | The app that reads input arguments and output, what traffic light color it would be in inputted time. User has an opportunity to enter time in 2 formats | |
|
|
||
| public class CommandLineArgs { | ||
|
|
||
| public static final String ANSI_RED = "\u001B[31m"; |
| @@ -0,0 +1,20 @@ | |||
| package Homework_1; | |||
| } catch (NumberFormatException | IOException exception) { | ||
|
|
||
| } | ||
| return -1; |
There was a problem hiding this comment.
| } catch (NumberFormatException | IOException exception) { | |
| } | |
| return -1; | |
| } catch (NumberFormatException | IOException exception) { | |
| return -1; | |
| } |
will it work this way?
| if (negativeInput(input)) { | ||
| System.out.println(ERROR); | ||
| } else if (input == 0) { | ||
| System.out.println(); | ||
| } else { | ||
| printResult(input); | ||
| } |
There was a problem hiding this comment.
| if (negativeInput(input)) { | |
| System.out.println(ERROR); | |
| } else if (input == 0) { | |
| System.out.println(); | |
| } else { | |
| printResult(input); | |
| } | |
| if (negativeInput(input)) { | |
| System.out.println(ERROR); | |
| } else { | |
| printResult(input); | |
| } |
and
private void printResult(int input) {
String output = "";
for (int i = 0; i < input; i++) {
output += "x";
}
System.out.println(output);
}
will it work this way?
| int counter = 0; | ||
| while (counter < result.length()) { | ||
| if (counter == result.length() - 1) { | ||
| System.out.print(result.charAt(counter)); | ||
| break; | ||
| } | ||
| System.out.print(result.charAt(counter) + ", "); | ||
| counter++; | ||
| } |
There was a problem hiding this comment.
| int counter = 0; | |
| while (counter < result.length()) { | |
| if (counter == result.length() - 1) { | |
| System.out.print(result.charAt(counter)); | |
| break; | |
| } | |
| System.out.print(result.charAt(counter) + ", "); | |
| counter++; | |
| } | |
| for (int i = 0; i < result.length(); i++) { | |
| if (i == result.length() - 1) { | |
| System.out.print(result.charAt(i)); | |
| break; | |
| } | |
| System.out.print(result.charAt(i) + ", "); | |
| } |
opt
| protected void trafficLightColorDetection(int sec) { | ||
| if (sec % 60 < 35) { | ||
| System.out.print(ANSI_GREEN + "Green light" + ANSI_RESET); | ||
| } else if (sec % 60 >= 35 && sec % 60 < 40 || sec % 60 >= 55) { |
There was a problem hiding this comment.
| } else if (sec % 60 >= 35 && sec % 60 < 40 || sec % 60 >= 55) { | |
| } else if (sec % 60 < 40 || sec % 60 >= 55) { |
| } | ||
| } | ||
|
|
||
| protected boolean isNegative(int input) { |
| return input < 0; | ||
| } | ||
|
|
||
| private boolean dayOverCheck(int input) { |
| return input <= 86399; | ||
| } | ||
|
|
||
| private boolean isDigit(String input) { |
There was a problem hiding this comment.
you can to combine isNegative, dayOverCheck and isDigit how validationInput for example
| public void run2(String filename) { | ||
| isCorrectFilename(filename); | ||
| try{ | ||
| Files.lines(Path.of(getPath(filename))).map(x->x.replaceAll("[,.]","")).forEach(System.out::println); |
There was a problem hiding this comment.
Path.of() don't exist in java 8
| private char[][] array; | ||
| private String strategy; | ||
| private String inputData; | ||
| private String result; | ||
| private int rows; | ||
| private int columns; |
There was a problem hiding this comment.
Opt: these should be either local variables or return values
| } | ||
| } | ||
|
|
||
| private void parseData(String s){ |
There was a problem hiding this comment.
Opt: As example, this method should return String array
| TrafficLight trafficLight = new TrafficLight(); | ||
| TrafficLightExtraMod trafficLightExtraMod = new TrafficLightExtraMod(); | ||
| if(args[0].equals("seconds")){ | ||
| trafficLight.run(); | ||
| } else { | ||
| trafficLightExtraMod.run(); | ||
| } |
There was a problem hiding this comment.
Opt: instantiate obj just if the requirement matches
|
Good job with HW_2! |
|
|
||
| public class Main { | ||
| public static void main(String[] args) { | ||
| Runner runner = new Runner(); |
There was a problem hiding this comment.
Also, if input is wrong, the app just shuts down. Really annoying in case you make a typo right before the end :)
There was a problem hiding this comment.
Have you played your own game?)
Sorry, can't approve a this state
| No setters. | ||
| */ | ||
|
|
||
| final class ImmutableClass { |
There was a problem hiding this comment.
Your class is mutable 100%



No description provided.