Skip to content
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

Fix duplicate files and wrong identation #2

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/main/java/soen/tutorial/ArithmeticOperation.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

public class ArithmeticOperation {

public Integer addOrSub(Integer a, Integer b)
{
public Integer addOrSub(Integer a, Integer b) {
if (a > b) {

Choose a reason for hiding this comment

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

Might as well shorten this code in the interest of quality :^)

Instead of

if (a > b) {
        return a - b;
} else {
	return a + b;
}

Do

return a > b ? a - b : a + b;

Copy link
Owner

Choose a reason for hiding this comment

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

Might as well shorten this code in the interest of quality :^)

Instead of

if (a > b) {
        return a - b;
} else {
	return a + b;
}

Do

return a > b ? a - b : a + b;

Not agree with this. The use of the ternary operation affects code readability is not a recommended practice.

Choose a reason for hiding this comment

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

Ah my bad you're right, nevermind my comment then

Copy link
Author

@bit172 bit172 Apr 2, 2021

Choose a reason for hiding this comment

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

I agree. Unless you are a 10x developer, those changes would affect code readability.

return a - b;
} else {
Expand Down
13 changes: 0 additions & 13 deletions src/main/java/soen/tutorial/ArithmeticOperations.java

This file was deleted.

23 changes: 8 additions & 15 deletions src/test/java/soen/tutorial/ArithmeticOperationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,19 @@

public class ArithmeticOperationTest {


@Test
public void testAdd()
{

ArithmeticOperation operations = new ArithmeticOperation();
Integer actual = operations.addOrSub(2, 6);
Integer expected = 8;
assertEquals(expected, actual);

}
@Test
public void testSub()
{
public void testAdd() {
ArithmeticOperation operations = new ArithmeticOperation();
Integer actual = operations.addOrSub(2, 6);
Integer expected = 8;
assertEquals(expected, actual);
Comment on lines +12 to +14

Choose a reason for hiding this comment

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

💡 Same for the one below

Suggested change
Integer actual = operations.addOrSub(2, 6);
Integer expected = 8;
assertEquals(expected, actual);
assertEquals(8, operations.addOrSub(2, 6));

}

@Test
public void testSub() {
ArithmeticOperation operations = new ArithmeticOperation();
Integer actual = operations.addOrSub(6, 2);
Integer expected = 4;
assertEquals(expected, actual);

}

}
31 changes: 0 additions & 31 deletions src/test/java/soen/tutorial/ArithmeticOperationsTest.java

This file was deleted.