Skip to content

Commit 8d41034

Browse files
OndrejVaneppicha
authored andcommitted
#5 Implement user input checks
- change percentage data type from integer to float - allow decimal values in percentage
1 parent 6cfce16 commit 8d41034

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/detectors/BusinessAsUsualDetectorImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ public class BusinessAsUsualDetectorImpl implements AntiPatternDetector {
2323
put("divisionOfIterationsWithRetrospective", new Configuration<Percentage>("divisionOfIterationsWithRetrospective",
2424
"Division of iterations with retrospective",
2525
"Minimum percentage of the total number of iterations with a retrospective (0,100)",
26-
"Percentage must be between 0 and 100",
27-
new Percentage(66)));
26+
"Percentage must be float number between 0 and 100",
27+
new Percentage(66.66f)));
2828
put("searchSubstringsWithRetrospective", new Configuration<String>("searchSubstringsWithRetrospective",
2929
"Search substrings with retrospective",
3030
"Substring that will be search in wikipages and activities",

src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/detectors/LongOrNonExistentFeedbackLoopsDetectorImpl.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ public class LongOrNonExistentFeedbackLoopsDetectorImpl implements AntiPatternDe
2828
new HashMap<>() {{
2929
put("divisionOfIterationsWithFeedbackLoop", new Configuration<Percentage>("divisionOfIterationsWithFeedbackLoop",
3030
"Division of iterations with feedback loop",
31-
"Minimum percentage of the total number of iterations with feedback loop (0,1)",
32-
"Percentage must be between 0 and 100",
33-
new Percentage(50)));
31+
"Minimum percentage of the total number of iterations with feedback loop (0,100)",
32+
"Percentage must be float number between 0 and 100",
33+
new Percentage(50.00f)));
3434
put("maxGapBetweenFeedbackLoopRate", new Configuration<PositiveFloat>("maxGapBetweenFeedbackLoopRate",
3535
"Maximum gap between feedback loop rate",
3636
"Value that multiplies average iteration length for given project. Result" +

src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/model/types/Percentage.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,22 @@ public class Percentage extends Number {
55
public static final float MAX_VALUE = 100;
66
public static final float MIN_VALUE = 0;
77

8-
private final int value;
8+
private final float value;
99

10-
public Percentage(int value) throws NumberFormatException {
10+
public Percentage(float value) throws NumberFormatException {
1111
if (value > MAX_VALUE || value < MIN_VALUE) {
1212
throw new NumberFormatException("Percentage should be between 0 and 100");
1313
}
1414
this.value = value;
1515
}
1616

1717
public static Percentage parsePercentage(String value) {
18-
return new Percentage(Integer.parseInt(value));
18+
return new Percentage(Float.parseFloat(value));
1919
}
2020

2121
@Override
2222
public int intValue() {
23-
return this.value;
23+
return (int) this.value;
2424
}
2525

2626
@Override
@@ -44,6 +44,6 @@ public String toString() {
4444
}
4545

4646
public float getValue() {
47-
return (float) value/100;
47+
return value /100;
4848
}
4949
}

0 commit comments

Comments
 (0)