From 90b1238abefdeac3cb76fd275669494606f11e6c Mon Sep 17 00:00:00 2001 From: Rex Date: Tue, 29 Jun 2021 23:12:57 -0400 Subject: [PATCH] Method/test case added --- LogginLab1.iml | 16 ++++++++++++ src/test/java/LogginLab.java | 42 ++++++++++++++++++++++++++++++++ src/test/java/LogginLabTest.java | 17 +++++++++++++ 3 files changed, 75 insertions(+) create mode 100644 LogginLab1.iml create mode 100644 src/test/java/LogginLab.java 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/test/java/LogginLab.java b/src/test/java/LogginLab.java new file mode 100644 index 0000000..d987ed3 --- /dev/null +++ b/src/test/java/LogginLab.java @@ -0,0 +1,42 @@ +import java.util.logging.Level; +import java.util.logging.Logger; + +public class LogginLab { + private final static Logger logger = Logger.getLogger(LogginLab.class.getName()); + + private Integer threshold = 0; + + public LogginLab() { + this.threshold = 0; + } + + public static void main(String[] args) { + + logger.log(Level.INFO, "Hello World!"); + logger.log(Level.SEVERE, "Terrible Error!"); + 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() { + return threshold; + } + + public void setThreshold(Integer threshold) { + this.threshold = threshold; + } + + public boolean thresholdExceeds(Integer limit) { + return (this.threshold > limit); + } + + public boolean thresholdReached(Integer limit){ + if (limit > this.threshold){ return true; } + else return false; + + } + // 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..838561a 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() { + LogginLab lab = new LogginLab(); + int reached = 2; + lab.setThreshold(reached); + + for (Integer i = 1; i <= reached; i++) { + if (lab.thresholdReached(i)) { + logger.log(Level.INFO, "Threshold not reached! It is " + i); + assertTrue(lab.thresholdReached(i)); + } else { + logger.log(Level.INFO, "Threshold finally reached!"); + assertFalse(lab.thresholdReached(i)); + + } + } + } } \ No newline at end of file