Skip to content

Fifth#7

Open
shlyapugin-anton wants to merge 6 commits intohyperskill:masterfrom
shlyapugin-anton:fifth
Open

Fifth#7
shlyapugin-anton wants to merge 6 commits intohyperskill:masterfrom
shlyapugin-anton:fifth

Conversation

@shlyapugin-anton
Copy link
Copy Markdown

Hi!
Check this out plz, btw probably I found a mistake in test output
I checked answer which I get by that program and find out that it is correct

Comment thread src/solver/Main.java
} No newline at end of file
public static void main(String[] args) {

makeGood maker = new makeGood();
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Strongly recommend having class names that start with an uppercase letter, not lowercase.

Comment thread src/solver/Main.java
try(Scanner scanner = new Scanner(file)) {
int n = scanner.nextInt();
int m = scanner.nextInt();
// n - число неизвестных (без ответа), m - число уравнений
Copy link
Copy Markdown

@aaaaaa2493 aaaaaa2493 Jan 9, 2019

Choose a reason for hiding this comment

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

Maybe you can write comments in English? Think about someone reading your code and improve the functionality. He won't understand anything in your comments. And also, consider using better names for the variables (this way you won't even use a comment to describe the code, the self-describing code is always better than a comment).

Comment thread src/solver/Main.java

matrix.steppedViewDown();
} catch (FileNotFoundException e) {
System.out.println("I hope that never happen");
Copy link
Copy Markdown

@aaaaaa2493 aaaaaa2493 Jan 9, 2019

Choose a reason for hiding this comment

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

Maybe there needs to be something more describing the exception. In case it happens you will know what causes the exception to happen and then fix the bug or add some readable output on what causes the exception to happen.

Comment thread src/solver/Matrix.java
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
class Matrix {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Let the code be more readable and add here an empty line to distinguish imports and the class definition.

Comment thread src/solver/Matrix.java
this.M = m;
}
// true - ненулевое
boolean checkValue(int i, int j) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remove the comment and rename the method something like "isNotZero".

Comment thread src/solver/Matrix.java
try (FileWriter writer = new FileWriter(file)) {
writer.write(s);
} catch (IOException e) {
System.out.printf("Exception");
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

If the program prints "Exception" it gives you nothing to fix it. It doesn't print where the exception happened. So, if you have a lot of these you wouldn't even know where the exception happened.

Comment thread src/solver/Matrix.java
return (this.checkNonzero(i + 1, j) || this.checkValue(i, j));
}
else {
return this.checkValue(i, j);
Copy link
Copy Markdown

@aaaaaa2493 aaaaaa2493 Jan 9, 2019

Choose a reason for hiding this comment

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

I see that you using "this" everywhere. It is not necessary to write in places where it is not ambiguous. When you have the local variable that has the same name as your class member variable then you need to use "this" and nowhere else.

Comment thread src/solver/Matrix.java
this.rows[i] = this.rows[j];
this.rows[j] = row;
}
String getString() {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Use empty lines to separate different methods.

Comment thread src/solver/Row.java
*/
class Row { // N на 1 больше, чем вход, т.к. тут я учитываю и ответ (то, что справа от равно)
int N;
ComplexNumber[] line = new ComplexNumber[1];
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You don't need to write an initial value for the array if you will rewrite it anyway. Like in the constructor.

Comment thread src/solver/makeGood.java
@@ -0,0 +1,45 @@
class makeGood {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

As I wrote above, the name of the class should start with an uppercase letter.

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