This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns life (:use clojure.test clojure.set)) | |
(def under-populated 1) | |
(def over-populated 4) | |
(def fertile 3) | |
(defn north [[x y]] [x (inc y)]) | |
(defn south [[x y]] [x (dec y)]) | |
(defn east [[x y]] [(inc x) y]) | |
(defn west [[x y]] [(dec x) y]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package payroll; | |
public class PayCalculator { | |
public static float calculate(double hours, | |
double rate, | |
boolean isHourlyWorker) { | |
if (hours < 0 || hours > 80) { | |
throw new RuntimeException("Hours out of range: " + hours); | |
} | |
float wages = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.junit.Test; | |
import static org.junit.Assert.assertEquals; | |
import static payroll.PayCalculator.calculate; | |
public class PayCalculatorTest { | |
private void assertPay(double expectedPay, double actualPay) { | |
assertEquals(expectedPay, actualPay, .001); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package payroll; | |
public class PayCalculator { | |
public static double calculate(double hours, | |
double rate, | |
boolean isHourlyWorker) { | |
if (hours < 0 || hours > 80) { | |
throw new RuntimeException("Hours out of range: " + hours); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package payroll; | |
public class PayCalculator { | |
private boolean isHourlyWorker; | |
public PayCalculator(boolean hourlyWorker) { | |
isHourlyWorker = hourlyWorker; | |
} | |
public double calculate(double hours, double rate) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package payroll; | |
public class ContractorCalculator extends PayCalculator { | |
public ContractorCalculator() { | |
super(false); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package payroll; | |
public class ContractorCalculator extends PayCalculator { | |
public ContractorCalculator() { | |
super(false); | |
} | |
public double calculate(double hours, double rate) { | |
if (hours < 0 || hours > 80) { | |
throw new RuntimeException("Hours out of range: " + hours); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package payroll; | |
public class ContractorCalculator extends PayCalculator { | |
public double calculate(double hours, double rate) { | |
validateHours(hours); | |
return hours * rate; | |
} | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RunWith(Suite.class) | |
@Suite.SuiteClasses({ | |
WrapperTest.DegenerateTests.class}) | |
public class WrapperTest { | |
public static class DegenerateTests { | |
@Test | |
public void emptyString() throws Exception { | |
assertThat(wrap("", 1), equalTo("")); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RunWith(Suite.class) | |
@Suite.SuiteClasses({ | |
WrapperTest.DegenerateTests.class, | |
WrapperTest.wrapWordsTest.class | |
}) | |
public class WrapperTest { | |
public static class DegenerateTests { | |
@Test | |
public void emptyString() throws Exception { |
OlderNewer