diff --git a/LogginLab1.iml b/LogginLab1.iml new file mode 100644 index 0000000..0ddf51c --- /dev/null +++ b/LogginLab1.iml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/java/LogginLab.java b/src/main/java/LogginLab.java index 11744ac..ae8d363 100644 --- a/src/main/java/LogginLab.java +++ b/src/main/java/LogginLab.java @@ -20,17 +20,13 @@ public static void main(String[] args) { } - public Integer getThreshold() { - return threshold; - } + public Integer getThreshold() { return threshold; } - public void setThreshold(Integer threshold) { - this.threshold = threshold; - } + public void setThreshold(Integer threshold) { this.threshold = threshold; } - public boolean thresholdExceeds(Integer limit) { - return (this.threshold > limit); - } + public boolean thresholdExceeds(Integer limit) { return (this.threshold > limit); } + + public boolean thresholdReached(Integer limit){ return (this.threshold < limit); } // Write a method called thresholdReached, returns true if argument 'limit' is over the threshold. // Write a test for the method in the Test class. diff --git a/src/test/java/LogginLabTest.java b/src/test/java/LogginLabTest.java index be1c95f..aeb02ae 100644 --- a/src/test/java/LogginLabTest.java +++ b/src/test/java/LogginLabTest.java @@ -31,4 +31,21 @@ public void thresholdExceeds() { } } } + @org.junit.Test + public void thresholdReached() { + Integer finalLimit = 5; + + LogginLab lab = new LogginLab(); + lab.setThreshold(finalLimit); + + for (Integer i = 1; i <= finalLimit; i++) { + if (lab.thresholdReached(i)) { + logger.log(Level.INFO, "Threshold finally reached!"+i); + assertTrue(lab.thresholdReached(i)); + } else { + logger.log(Level.INFO, "Threshold is too far"); + assertFalse(lab.thresholdReached(i)); + } + } + } } \ No newline at end of file