Skip to content
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
16 changes: 15 additions & 1 deletion src/main/java/com/codacy/utils/Math.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,23 @@
public class Math {

private int magicNumber;
int some = 1;

public Math(int magicNumber) {
this.magicNumber = magicNumber;
}

/**
* Adds 2 numbers, unless there is a magic number on the second argument
*/
public int magicAdd(int x, int y) {
if (y == magicNumber) {
System.out.println("hey");
System.out.println("hey");
System.out.println("hey");
System.out.println("hey");
System.out.println("hey");
System.out.println("hey");
System.out.println("hey");
System.out.println("hey");
System.out.println("hey");
System.out.println("hey");
Expand All @@ -21,6 +28,13 @@ public int magicAdd(int x, int y) {
System.out.println("hey");
return y - x;
} else {
System.out.println("hey");
System.out.println("hey");
System.out.println("hey");
System.out.println("hey");
System.out.println("hey");
System.out.println("hey");
System.out.println("hey");
System.out.println("hey");
System.out.println("hey");
System.out.println("hey");
Expand Down
7 changes: 2 additions & 5 deletions src/main/java/com/codacy/utils/Math2.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ public class Math2 {
public Math2(int magicNumber) {
this.magicNumber = magicNumber;
}

/**
* Adds 2 numbers, unless there is a magic number on the second argument
*/
Expand All @@ -16,8 +15,7 @@ public int magicAdd(int x, int y) {
System.out.println("hey");
System.out.println("hey");
System.out.println("hey");
System.out.println("hey");
System.out.println("hey");
System.out.println("hey");;;;
System.out.println("hey");
return y - x;
} else {
Expand All @@ -36,8 +34,7 @@ public int magicAdd(int x, int y) {
System.out.println("hey");
System.out.println("hey");
System.out.println("hey");
System.out.println("hey");
return x + y;
return y + x;
}
}
}
10 changes: 5 additions & 5 deletions src/test/java/com/codacy/utils/Math2Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ public void shouldAddNumbers() {
}

// Uncomment this to have 100% coverage
@Test
public void shouldSubtractIfMagicNumber() {
Math2 math = new Math2(4);
assertEquals(1, math.magicAdd(3, 4));
}
// @Test
// public void shouldSubtractIfMagicNumber() {
// Math2 math = new Math2(4);
// assertEquals(1, math.magicAdd(3, 4));
// }
}