diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..b76134b Binary files /dev/null and b/.DS_Store differ 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/.DS_Store b/src/.DS_Store new file mode 100644 index 0000000..dda5682 Binary files /dev/null and b/src/.DS_Store differ diff --git a/src/main/java/LogginLab.java b/src/main/java/LogginLab.java index 11744ac..c2304b2 100644 --- a/src/main/java/LogginLab.java +++ b/src/main/java/LogginLab.java @@ -7,7 +7,7 @@ public class LogginLab { private Integer threshold = 0; public LogginLab() { - this.threshold = 0; + this.threshold = 5; } public static void main(String[] args) { @@ -17,7 +17,6 @@ public static void main(String[] args) { logger.log(Level.WARNING, "Not So Bad Error!"); logger.log(Level.INFO, "****\n\tAt ZipCode, \n\twe don't use System.out.Println \n\tuntil we've earned the right.\n****"); - } public Integer getThreshold() { @@ -33,5 +32,13 @@ public boolean thresholdExceeds(Integer 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. + + + public boolean thresholdReached(Integer limit) { + return limit > this.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..120f5f1 100644 --- a/src/test/java/LogginLabTest.java +++ b/src/test/java/LogginLabTest.java @@ -23,7 +23,7 @@ public void thresholdExceeds() { for (Integer i = 1; i <= finalLimit; i++) { if (lab.thresholdExceeds(i)) { - logger.log(Level.INFO, "Threshold not reached! It is "+i); + logger.log(Level.INFO, "Threshold not reached! It is " + i); assertTrue(lab.thresholdExceeds(i)); } else { logger.log(Level.INFO, "Threshold finally reached!"); @@ -31,4 +31,22 @@ 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 has been reached!"); + assertTrue(lab.thresholdReached(i)); + } else { + logger.log(Level.INFO, "Threshold has not been reached! It is " + i); + assertFalse(lab.thresholdReached(i)); + } + } + + } } \ No newline at end of file