diff --git a/.DS_Store b/.DS_Store
new file mode 100644
index 00000000..e3f751c1
Binary files /dev/null and b/.DS_Store differ
diff --git a/koans/.DS_Store b/koans/.DS_Store
new file mode 100644
index 00000000..5172429f
Binary files /dev/null and b/koans/.DS_Store differ
diff --git a/koans/app/config/PathToEnlightenment.xml b/koans/app/config/PathToEnlightenment.xml
index dd104446..9a999300 100755
--- a/koans/app/config/PathToEnlightenment.xml
+++ b/koans/app/config/PathToEnlightenment.xml
@@ -6,52 +6,24 @@
-
-
-
-
-
-
+
+
+
-
-
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/koans/src/.DS_Store b/koans/src/.DS_Store
new file mode 100644
index 00000000..826071ba
Binary files /dev/null and b/koans/src/.DS_Store differ
diff --git a/koans/src/advanced/AboutMocks.java b/koans/src/advanced/AboutMocks.java
deleted file mode 100755
index fd03e982..00000000
--- a/koans/src/advanced/AboutMocks.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package advanced;
-
-import com.sandwich.koan.Koan;
-
-import static com.sandwich.util.Assert.fail;
-
-public class AboutMocks {
-
- static interface Collaborator {
- public void doBusinessStuff();
- }
-
- static class ExplosiveCollaborator implements Collaborator {
- public void doBusinessStuff() {
- fail("Default collaborator's behavior is complicating testing.");
- }
- }
-
- static class ClassUnderTest {
- Collaborator c;
-
- public ClassUnderTest() {
- // default is to pass a broken Collaborator, test should pass one
- // that doesn't throw exception
- this(new ExplosiveCollaborator());
- }
-
- public ClassUnderTest(Collaborator c) {
- this.c = c;
- }
-
- public boolean doSomething() {
- c.doBusinessStuff();
- return true;
- }
- }
-
- @Koan
- public void simpleAnonymousMock() {
- // HINT: pass a safe Collaborator implementation to constructor
- // new ClassUnderTest(new Collaborator(){... it should not be the
- // objective of this test to test that collaborator, so replace it
- new ClassUnderTest().doSomething();
- }
-
-}
diff --git a/koans/src/beginner/.DS_Store b/koans/src/beginner/.DS_Store
new file mode 100644
index 00000000..5008ddfc
Binary files /dev/null and b/koans/src/beginner/.DS_Store differ
diff --git a/koans/src/beginner/AboutBitwiseOperators.java b/koans/src/beginner/AboutBitwiseOperators.java
index b2d17451..3aa63f81 100644
--- a/koans/src/beginner/AboutBitwiseOperators.java
+++ b/koans/src/beginner/AboutBitwiseOperators.java
@@ -38,28 +38,4 @@ public void dontMistakeEqualsForEqualsEquals() {
assertEquals(i, __);
// How could you write the condition 'with a twist' to avoid this trap?
}
-
- @Koan
- public void aboutBitShiftingRightShift() {
- int rightShift = 8;
- rightShift = rightShift >> 1;
- assertEquals(rightShift, __);
- }
-
- @Koan
- public void aboutBitShiftingLeftShift() {
- int leftShift = 0x80000000; // Is this number positive or negative?
- leftShift = leftShift << 1;
- assertEquals(leftShift, __);
- }
-
- @Koan
- public void aboutBitShiftingRightUnsigned() {
- int rightShiftNegativeStaysNegative = 0x80000000;
- rightShiftNegativeStaysNegative = rightShiftNegativeStaysNegative >> 4;
- assertEquals(rightShiftNegativeStaysNegative, __);
- int unsignedRightShift = 0x80000000; // always fills with 0
- unsignedRightShift >>>= 4; // Just like +=
- assertEquals(unsignedRightShift, __);
- }
}
diff --git a/koans/src/beginner/AboutExceptions.java b/koans/src/beginner/AboutExceptions.java
deleted file mode 100644
index b54ee194..00000000
--- a/koans/src/beginner/AboutExceptions.java
+++ /dev/null
@@ -1,166 +0,0 @@
-package beginner;
-
-import com.sandwich.koan.Koan;
-
-import java.io.IOException;
-
-import static com.sandwich.koan.constant.KoanConstants.__;
-import static com.sandwich.util.Assert.assertEquals;
-
-public class AboutExceptions {
-
- private void doStuff() throws IOException {
- throw new IOException();
- }
-
- @Koan
- public void catchCheckedExceptions() {
- String s;
- try {
- doStuff();
- s = "code ran normally";
- } catch (IOException e) {
- s = "exception thrown";
- }
- assertEquals(s, __);
- }
-
- @Koan
- public void useFinally() {
- String s = "";
- try {
- doStuff();
- s += "code ran normally";
- } catch (IOException e) {
- s += "exception thrown";
- } finally {
- s += " and finally ran as well";
- }
- assertEquals(s, __);
- }
-
- @Koan
- public void finallyWithoutCatch() {
- String s = "";
- try {
- s = "code ran normally";
- } finally {
- s += " and finally ran as well";
- }
- assertEquals(s, __);
- }
-
- private void tryCatchFinallyWithVoidReturn(StringBuilder whatHappened) {
- try {
- whatHappened.append("did something dangerous");
- doStuff();
- } catch (IOException e) {
- whatHappened.append("; the catch block executed");
- return;
- } finally {
- whatHappened.append(", but so did the finally!");
- }
- }
-
- @Koan
- public void finallyIsAlwaysRan() {
- StringBuilder whatHappened = new StringBuilder();
- tryCatchFinallyWithVoidReturn(whatHappened);
- assertEquals(whatHappened.toString(), __);
- }
-
- @SuppressWarnings("finally")
- // this is suppressed because returning in finally block is obviously a compiler warning
- private String returnStatementsEverywhere(StringBuilder whatHappened) {
- try {
- whatHappened.append("try");
- doStuff();
- return "from try";
- } catch (IOException e) {
- whatHappened.append(", catch");
- return "from catch";
- } finally {
- whatHappened.append(", finally");
- // Think about how bad an idea it is to put a return statement in the finally block
- // DO NOT DO THIS!
- return "from finally";
- }
- }
-
- @Koan
- public void returnInFinallyBlock() {
- StringBuilder whatHappened = new StringBuilder();
- // Which value will be returned here?
- assertEquals(returnStatementsEverywhere(whatHappened), __);
- assertEquals(whatHappened.toString(), __);
- }
-
- private void doUncheckedStuff() {
- throw new RuntimeException();
- }
-
- @Koan
- public void catchUncheckedExceptions() {
- // What do you need to do to catch the unchecked exception?
- doUncheckedStuff();
- }
-
- @SuppressWarnings("serial")
- static class ParentException extends Exception {
- }
-
- @SuppressWarnings("serial")
- static class ChildException extends ParentException {
- }
-
- private void throwIt() throws ParentException {
- throw new ChildException();
- }
-
- @Koan
- public void catchOrder() {
- String s = "";
- try {
- throwIt();
- } catch (ChildException e) {
- s = "ChildException";
- } catch (ParentException e) {
- s = "ParentException";
- }
- assertEquals(s, __);
- }
-
- @Koan
- public void failArgumentValidationWithAnIllegalArgumentException() {
- // This koan demonstrates the use of exceptions in argument validation
- String s = "";
- try {
- s += validateUsingIllegalArgumentException(null);
- } catch (IllegalArgumentException ex) {
- s = "caught an IllegalArgumentException";
- }
- assertEquals(s, __);
- }
-
- @Koan
- public void passArgumentValidationWithAnIllegalArgumentException() {
- // This koan demonstrates the use of exceptions in argument validation
- String s = "";
- try {
- s += validateUsingIllegalArgumentException("valid");
- } catch (IllegalArgumentException ex) {
- s = "caught an IllegalArgumentException";
- }
- assertEquals(s, __);
- }
-
- private int validateUsingIllegalArgumentException(String str) {
- // This is effective and both the evaluation and the error message
- // can be tailored which can be particularly handy if you're guarding
- // against more than null values
- if (null == str) {
- throw new IllegalArgumentException("str should not be null");
- }
- return str.length();
- }
-}
diff --git a/koans/src/beginner/AboutPrimitives.java b/koans/src/beginner/AboutPrimitives.java
deleted file mode 100644
index f8a240b5..00000000
--- a/koans/src/beginner/AboutPrimitives.java
+++ /dev/null
@@ -1,227 +0,0 @@
-package beginner;
-
-import com.sandwich.koan.Koan;
-
-import static com.sandwich.koan.constant.KoanConstants.__;
-import static com.sandwich.util.Assert.assertEquals;
-
-public class AboutPrimitives {
-
- @Koan
- public void wholeNumbersAreOfTypeInt() {
- assertEquals(getType(1), __); // hint: int.class
- }
-
- @Koan
- public void primitivesOfTypeIntHaveAnObjectTypeInteger() {
- Object number = 1;
- assertEquals(getType(number), __);
-
- // Primitives can be automatically changed into their object type via a process called auto-boxing
- // We will explore this in more detail in intermediate.AboutAutoboxing
- }
-
- @Koan
- public void integersHaveAFairlyLargeRange() {
- assertEquals(Integer.MIN_VALUE, __);
- assertEquals(Integer.MAX_VALUE, __);
- }
-
- @Koan
- public void integerSize() {
- assertEquals(Integer.SIZE, __); // This is the amount of bits used to store an int
- }
-
- @Koan
- public void wholeNumbersCanAlsoBeOfTypeLong() {
- assertEquals(getType(1L), __);
- }
-
- @Koan
- public void primitivesOfTypeLongHaveAnObjectTypeLong() {
- Object number = 1L;
- assertEquals(getType(number), __);
- }
-
- @Koan
- public void longsHaveALargerRangeThanInts() {
- assertEquals(Long.MIN_VALUE, __);
- assertEquals(Long.MAX_VALUE, __);
- }
-
- @Koan
- public void longSize() {
- assertEquals(Long.SIZE, __);
- }
-
- @Koan
- public void wholeNumbersCanAlsoBeOfTypeShort() {
- assertEquals(getType((short) 1), __); // The '(short)' is called an explicit cast - to type 'short'
- }
-
- @Koan
- public void primitivesOfTypeShortHaveAnObjectTypeShort() {
- Object number = (short) 1;
- assertEquals(getType(number), __);
- }
-
- @Koan
- public void shortsHaveASmallerRangeThanInts() {
- assertEquals(Short.MIN_VALUE, __); // hint: You'll need an explicit cast
- assertEquals(Short.MAX_VALUE, __);
- }
-
- @Koan
- public void shortSize() {
- assertEquals(Short.SIZE, __);
- }
-
- @Koan
- public void wholeNumbersCanAlsoBeOfTypeByte() {
- assertEquals(getType((byte) 1), __);
- }
-
- @Koan
- public void primitivesOfTypeByteHaveAnObjectTypeByte() {
- Object number = (byte) 1;
- assertEquals(getType(number), __);
- }
-
- @Koan
- public void bytesHaveASmallerRangeThanShorts() {
- assertEquals(Byte.MIN_VALUE, __);
- assertEquals(Byte.MAX_VALUE, __);
-
- // Why would you use short or byte considering that you need to do explicit casts?
- }
-
- @Koan
- public void byteSize() {
- assertEquals(Byte.SIZE, __);
- }
-
- @Koan
- public void wholeNumbersCanAlsoBeOfTypeChar() {
- assertEquals(getType((char) 1), __);
- }
-
- @Koan
- public void singleCharactersAreOfTypeChar() {
- assertEquals(getType('a'), __);
- }
-
- @Koan
- public void primitivesOfTypeCharHaveAnObjectTypeCharacter() {
- Object number = (char) 1;
- assertEquals(getType(number), __);
- }
-
- @Koan
- public void charsCanOnlyBePositive() {
- assertEquals((int) Character.MIN_VALUE, __);
- assertEquals((int) Character.MAX_VALUE, __);
-
- // Why did we cast MIN_VALUE and MAX_VALUE to int? Try it without the cast.
- }
-
- @Koan
- public void charSize() {
- assertEquals(Character.SIZE, __);
- }
-
- @Koan
- public void decimalNumbersAreOfTypeDouble() {
- assertEquals(getType(1.0), __);
- }
-
- @Koan
- public void primitivesOfTypeDoubleCanBeDeclaredWithoutTheDecimalPoint() {
- assertEquals(getType(1d), __);
- }
-
- @Koan
- public void primitivesOfTypeDoubleCanBeDeclaredWithExponents() {
- assertEquals(getType(1e3), __);
- assertEquals(1.0e3, __);
- assertEquals(1E3, __);
- }
-
- @Koan
- public void primitivesOfTypeDoubleHaveAnObjectTypeDouble() {
- Object number = 1.0;
- assertEquals(getType(number), __);
- }
-
- @Koan
- public void doublesHaveALargeRange() {
- assertEquals(Double.MIN_VALUE, __);
- assertEquals(Double.MAX_VALUE, __);
- }
-
- @Koan
- public void doubleSize() {
- assertEquals(Double.SIZE, __);
- }
-
- @Koan
- public void decimalNumbersCanAlsoBeOfTypeFloat() {
- assertEquals(getType(1f), __);
- }
-
- @Koan
- public void primitivesOfTypeFloatCanBeDeclaredWithExponents() {
- assertEquals(getType(1e3f), __);
- assertEquals(1.0e3f, __);
- assertEquals(1E3f, __);
- }
-
- @Koan
- public void primitivesOfTypeFloatHaveAnObjectTypeFloat() {
- Object number = 1f;
- assertEquals(getType(number), __);
- }
-
- @Koan
- public void floatsHaveASmallerRangeThanDoubles() {
- assertEquals(Float.MIN_VALUE, __);
- assertEquals(Float.MAX_VALUE, __);
- }
-
- @Koan
- public void floatSize() {
- assertEquals(Float.SIZE, __);
- }
-
- private Class> getType(int value) {
- return int.class;
- }
-
- private Class> getType(long value) {
- return long.class;
- }
-
- private Class> getType(float value) {
- return float.class;
- }
-
- private Class> getType(double value) {
- return double.class;
- }
-
- private Class> getType(byte value) {
- return byte.class;
- }
-
- private Class> getType(char value) {
- return char.class;
- }
-
- private Class> getType(short value) {
- return short.class;
- }
-
- private Class> getType(Object value) {
- return value.getClass();
- }
-
-}
diff --git a/koans/src/intermediate/.DS_Store b/koans/src/intermediate/.DS_Store
new file mode 100644
index 00000000..5008ddfc
Binary files /dev/null and b/koans/src/intermediate/.DS_Store differ
diff --git a/koans/src/intermediate/AboutAutoboxing.java b/koans/src/intermediate/AboutAutoboxing.java
deleted file mode 100755
index 4063eb2d..00000000
--- a/koans/src/intermediate/AboutAutoboxing.java
+++ /dev/null
@@ -1,52 +0,0 @@
-package intermediate;
-
-import com.sandwich.koan.Koan;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import static com.sandwich.koan.constant.KoanConstants.__;
-import static com.sandwich.util.Assert.assertEquals;
-
-public class AboutAutoboxing {
-
- @Koan
- public void addPrimitivesToCollection() {
- List list = new ArrayList();
- list.add(0, new Integer(42));
- assertEquals(list.get(0), __);
- }
-
- @Koan
- public void addPrimitivesToCollectionWithAutoBoxing() {
- List list = new ArrayList();
- list.add(0, 42);
- assertEquals(list.get(0), __);
- }
-
- @Koan
- public void migrateYourExistingCodeToAutoBoxingWithoutFear() {
- List list = new ArrayList();
- list.add(0, new Integer(42));
- assertEquals(list.get(0), __);
-
- list.add(1, 84);
- assertEquals(list.get(1), __);
- }
-
- @Koan
- public void allPrimitivesCanBeAutoboxed() {
- List doubleList = new ArrayList();
- doubleList.add(0, new Double(42));
- assertEquals(doubleList.get(0), __);
-
- List longList = new ArrayList();
- longList.add(0, new Long(42));
- assertEquals(longList.get(0), __);
-
- List characterList = new ArrayList();
- characterList.add(0, new Character('z'));
- assertEquals(characterList.get(0), __);
- }
-
-}
diff --git a/koans/src/intermediate/AboutComparison.java b/koans/src/intermediate/AboutComparison.java
deleted file mode 100644
index ee58ab64..00000000
--- a/koans/src/intermediate/AboutComparison.java
+++ /dev/null
@@ -1,83 +0,0 @@
-package intermediate;
-
-import com.sandwich.koan.Koan;
-
-import java.util.Arrays;
-import java.util.Comparator;
-
-import static com.sandwich.koan.constant.KoanConstants.__;
-import static com.sandwich.util.Assert.assertEquals;
-
-public class AboutComparison {
-
- @Koan
- public void compareObjects() {
- String a = "abc";
- String b = "bcd";
- assertEquals(a.compareTo(b), __);
- assertEquals(a.compareTo(a), __);
- assertEquals(b.compareTo(a), __);
- }
-
- static class Car implements Comparable {
- int horsepower;
-
- // For an explanation for this implementation look at
- // http://download.oracle.com/javase/6/docs/api/java/lang/Comparable.html#compareTo(T)
- public int compareTo(Car o) {
- return horsepower - o.horsepower;
- }
-
- }
-
- @Koan
- public void makeObjectsComparable() {
- Car vwbeetle = new Car();
- vwbeetle.horsepower = 50;
- Car porsche = new Car();
- porsche.horsepower = 300;
- assertEquals(vwbeetle.compareTo(porsche), __);
- }
-
- static class RaceHorse {
- int speed;
- int age;
-
- @Override
- public String toString() {
- return "Speed: " + speed + " Age: " + age;
- }
- }
-
- static class HorseSpeedComparator implements Comparator {
- public int compare(RaceHorse o1, RaceHorse o2) {
- return o1.speed - o2.speed;
- }
- }
-
- static class HorseAgeComparator implements Comparator {
- public int compare(RaceHorse o1, RaceHorse o2) {
- return o1.age - o2.age;
- }
- }
-
- @Koan
- public void makeObjectsComparableWithoutComparable() {
- RaceHorse lindy = new RaceHorse();
- lindy.age = 10;
- lindy.speed = 2;
- RaceHorse lightning = new RaceHorse();
- lightning.age = 2;
- lightning.speed = 10;
- RaceHorse slowy = new RaceHorse();
- slowy.age = 12;
- slowy.speed = 1;
-
- RaceHorse[] horses = {lindy, slowy, lightning};
-
- Arrays.sort(horses, new HorseAgeComparator());
- assertEquals(horses[0], __);
- Arrays.sort(horses, new HorseSpeedComparator());
- assertEquals(horses[0], __);
- }
-}
diff --git a/koans/src/intermediate/AboutDates.java b/koans/src/intermediate/AboutDates.java
deleted file mode 100644
index 6a157b76..00000000
--- a/koans/src/intermediate/AboutDates.java
+++ /dev/null
@@ -1,73 +0,0 @@
-package intermediate;
-
-import com.sandwich.koan.Koan;
-
-import java.text.DateFormat;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Date;
-
-import static com.sandwich.koan.constant.KoanConstants.__;
-import static com.sandwich.util.Assert.assertEquals;
-
-
-public class AboutDates {
-
- private Date date = new Date(100010001000L);
-
- @Koan
- public void dateToString() {
- assertEquals(date.toString(), __);
- }
-
- @Koan
- public void changingDateValue() {
- int oneHourInMiliseconds = 3600000;
- date.setTime(date.getTime() + oneHourInMiliseconds);
- assertEquals(date.toString(), __);
- }
-
- @Koan
- public void usingCalendarToChangeDates() {
- Calendar cal = Calendar.getInstance();
- cal.setTime(date);
- cal.add(Calendar.MONTH, 1);
- assertEquals(cal.getTime().toString(), __);
- }
-
- @Koan
- public void usingRollToChangeDatesDoesntWrapOtherFields() {
- Calendar cal = Calendar.getInstance();
- cal.setTime(date);
- cal.roll(Calendar.MONTH, 12);
- assertEquals(cal.getTime().toString(), __);
- }
-
- @Koan
- public void usingDateFormatToFormatDate() {
- String formattedDate = DateFormat.getDateInstance().format(date);
- assertEquals(formattedDate, __);
- }
-
- @Koan
- public void usingDateFormatToFormatDateShort() {
- String formattedDate = DateFormat.getDateInstance(DateFormat.SHORT).format(date);
- assertEquals(formattedDate, __);
- }
-
- @Koan
- public void usingDateFormatToFormatDateFull() {
- String formattedDate = DateFormat.getDateInstance(DateFormat.FULL).format(date);
- // There is also DateFormat.MEDIUM and DateFormat.LONG... you get the idea ;-)
- assertEquals(formattedDate, __);
- }
-
- @Koan
- public void usingDateFormatToParseDates() throws ParseException {
- DateFormat dateFormat = new SimpleDateFormat("MM-dd-yyyy");
- Date date2 = dateFormat.parse("01-01-2000");
- assertEquals(date2.toString(), __);
- // What happened to the time? What do you need to change to keep the time as well?
- }
-}
diff --git a/koans/src/intermediate/AboutEquality.java b/koans/src/intermediate/AboutEquality.java
deleted file mode 100644
index f3f50e8e..00000000
--- a/koans/src/intermediate/AboutEquality.java
+++ /dev/null
@@ -1,128 +0,0 @@
-package intermediate;
-
-import com.sandwich.koan.Koan;
-
-import static com.sandwich.koan.constant.KoanConstants.__;
-import static com.sandwich.util.Assert.assertEquals;
-
-public class AboutEquality {
- // This suite of Koans expands on the concepts introduced in beginner.AboutEquality
-
- @Koan
- public void sameObject() {
- Object a = new Object();
- Object b = a;
- assertEquals(a == b, __);
- }
-
- @Koan
- public void equalObject() {
- Integer a = new Integer(1);
- Integer b = new Integer(1);
- assertEquals(a.equals(b), __);
- assertEquals(b.equals(a), __);
- }
-
- @Koan
- public void noObjectShouldBeEqualToNull() {
- assertEquals(new Object().equals(null), __);
- }
-
- static class Car {
- private String name = "";
- private int horsepower = 0;
-
- public Car(String s, int p) {
- name = s;
- horsepower = p;
- }
-
- @Override
- public boolean equals(Object other) {
- // Change this implementation to match the equals contract
- // Car objects with same horsepower and name values should be considered equal
- // http://download.oracle.com/javase/6/docs/api/java/lang/Object.html#equals(java.lang.Object)
- return false;
- }
-
- @Override
- public int hashCode() {
- // @see http://download.oracle.com/javase/6/docs/api/java/lang/Object.html#hashCode()
- return super.hashCode();
- }
- }
-
- @Koan
- public void equalForOwnObjects() {
- Car car1 = new Car("Beetle", 50);
- Car car2 = new Car("Beetle", 50);
- // @see Car.equals (around line 45) for the place to solve this
- assertEquals(car1.equals(car2), true);
- assertEquals(car2.equals(car1), true);
- }
-
- @Koan
- public void unequalForOwnObjects() {
- Car car1 = new Car("Beetle", 50);
- Car car2 = new Car("Porsche", 300);
- // @see Car.equals (around line 45) for the place to solve this
- assertEquals(car1.equals(car2), false);
- }
-
- @Koan
- public void unequalForOwnObjectsWithDifferentType() {
- Car car1 = new Car("Beetle", 50);
- String s = "foo";
- // @see Car.equals (around line 45) for the place to solve this
- assertEquals(car1.equals(s), false);
- }
-
- @Koan
- public void equalNullForOwnObjects() {
- Car car1 = new Car("Beetle", 50);
- // @see Car.equals (around line 45) for the place to solve this
- assertEquals(car1.equals(null), false);
- }
-
- @Koan
- public void ownHashCode() {
- // As a general rule: When you override equals you should override
- // hash code
- // Read the hash code contract to figure out why
- // http://download.oracle.com/javase/6/docs/api/java/lang/Object.html#hashCode()
-
- // Implement Car.hashCode around line 51 so that the following assertions pass
- Car car1 = new Car("Beetle", 50);
- Car car2 = new Car("Beetle", 50);
- assertEquals(car1.equals(car2), true);
- assertEquals(car1.hashCode() == car2.hashCode(), true);
- }
-
- static class Chicken {
- String color = "green";
-
- @Override
- public int hashCode() {
- return 4000;
- }
-
- @Override
- public boolean equals(Object other) {
- if (!(other instanceof Chicken))
- return false;
- return ((Chicken) other).color.equals(color);
- }
- }
-
- @Koan
- public void ownHashCodeImplementationPartTwo() {
- Chicken chicken1 = new Chicken();
- chicken1.color = "black";
- Chicken chicken2 = new Chicken();
- assertEquals(chicken1.equals(chicken2), __);
- assertEquals(chicken1.hashCode() == chicken2.hashCode(), __);
- // Does this still fit the hashCode contract? Why (not)?
- // Fix the Chicken class to correct this.
- }
-
-}
diff --git a/koans/src/intermediate/AboutInnerClasses.java b/koans/src/intermediate/AboutInnerClasses.java
deleted file mode 100644
index 8d9c7d0f..00000000
--- a/koans/src/intermediate/AboutInnerClasses.java
+++ /dev/null
@@ -1,150 +0,0 @@
-package intermediate;
-
-import com.sandwich.koan.Koan;
-
-import static com.sandwich.koan.constant.KoanConstants.__;
-import static com.sandwich.util.Assert.assertEquals;
-
-public class AboutInnerClasses {
-
- interface Ignoreable {
- String ignoreAll();
- }
-
- class Inner {
- public String doStuff() {
- return "stuff";
- }
-
- public int returnOuter() {
- return x;
- }
- }
-
- @Koan
- public void creatingInnerClassInstance() {
- Inner someObject = new Inner();
- assertEquals(someObject.doStuff(), __);
- }
-
- @Koan
- public void creatingInnerClassInstanceWithOtherSyntax() {
- AboutInnerClasses.Inner someObject = this.new Inner();
- assertEquals(someObject.doStuff(), __);
- }
-
- private int x = 10;
-
- @Koan
- public void accessingOuterClassMembers() {
- Inner someObject = new Inner();
- assertEquals(someObject.returnOuter(), __);
- }
-
- @Koan
- public void innerClassesInMethods() {
- class MethodInnerClass {
- int oneHundred() {
- return 100;
- }
- }
- assertEquals(new MethodInnerClass().oneHundred(), __);
- // Where can you use this class?
- }
-
- class AnotherInnerClass {
- int thousand() {
- return 1000;
- }
-
- AnotherInnerClass crazyReturn() {
- class SpecialInnerClass extends AnotherInnerClass {
- int thousand() {
- return 2000;
- }
- }
- ;
- return new SpecialInnerClass();
- }
- }
-
- @Koan
- public void innerClassesInMethodsThatEscape() {
- AnotherInnerClass ic = new AnotherInnerClass();
- assertEquals(ic.thousand(), __);
- AnotherInnerClass theCrazyIC = ic.crazyReturn();
- assertEquals(theCrazyIC.thousand(), __);
- }
-
- int theAnswer() {
- return 42;
- }
-
- @Koan
- public void creatingAnonymousInnerClasses() {
- AboutInnerClasses anonymous = new AboutInnerClasses() {
- int theAnswer() {
- return 23;
- }
- };// <- Why do you need a semicolon here?
- assertEquals(anonymous.theAnswer(), __);
- }
-
- @Koan
- public void creatingAnonymousInnerClassesToImplementInterface() {
- Ignoreable ignoreable = new Ignoreable() {
- public String ignoreAll() {
- return null;
- }
- }; // Complete the code so that the statement below is correct.
- // Look at the koan above for inspiration
- assertEquals(ignoreable.ignoreAll(), "SomeInterestingString");
- // Did you just created an object of an interface type?
- // Or did you create a class that implemented this interface and
- // an object of that type?
- }
-
- @Koan
- public void innerClassAndInheritance() {
- Inner someObject = new Inner();
- // The statement below is obvious...
- // Try to change the 'Inner' below to "AboutInnerClasses'
- // Why do you get an error?
- // What does that imply for inner classes and inheritance?
- assertEquals(someObject instanceof Inner, __);
- }
-
- class OtherInner extends AboutInnerClasses {
- }
-
- @Koan
- public void innerClassAndInheritanceOther() {
- OtherInner someObject = new OtherInner();
- // What do you expect here?
- // Compare this result with the last koan. What does that mean?
- assertEquals(someObject instanceof AboutInnerClasses, __);
- }
-
- static class StaticInnerClass {
- public int importantNumber() {
- return 3;
- }
- }
-
- @Koan
- public void staticInnerClass() {
- StaticInnerClass someObject = new StaticInnerClass();
- assertEquals(someObject.importantNumber(), __);
- // What happens if you try to access 'x' or 'theAnswer' from the outer class?
- // What does this mean for static inner classes?
- // Try to create a sub package of this package which is named 'StaticInnerClass'
- // Does it work? Why not?
- }
-
- @Koan
- public void staticInnerClassFullyQualified() {
- AboutInnerClasses.StaticInnerClass someObject = new AboutInnerClasses.StaticInnerClass();
- assertEquals(someObject.importantNumber(), __);
- }
-
-}
diff --git a/koans/src/intermediate/AboutLocale.java b/koans/src/intermediate/AboutLocale.java
deleted file mode 100644
index 48729987..00000000
--- a/koans/src/intermediate/AboutLocale.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package intermediate;
-
-import com.sandwich.koan.Koan;
-
-import java.text.DateFormat;
-import java.text.NumberFormat;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.Locale;
-
-import static com.sandwich.koan.constant.KoanConstants.__;
-import static com.sandwich.util.Assert.assertEquals;
-
-public class AboutLocale {
-
- @Koan
- public void localizedOutputOfDates() {
- Calendar cal = Calendar.getInstance();
- cal.set(2011, 3, 3);
- Date date = cal.getTime();
- Locale localeBR = new Locale("pt", "BR"); // portuguese, Brazil
- DateFormat dateformatBR = DateFormat.getDateInstance(DateFormat.FULL, localeBR);
- assertEquals(dateformatBR.format(date), __);
-
- Locale localeJA = new Locale("ja"); // Japan
- DateFormat dateformatJA = DateFormat.getDateInstance(DateFormat.FULL, localeJA);
- // Well if you don't know how to type these characters, try "de", "it" or "us" ;-)
- assertEquals(dateformatJA.format(date), __);
- }
-
- @Koan
- public void getCountryInformation() {
- Locale locBR = new Locale("pt", "BR");
- assertEquals(locBR.getDisplayCountry(), __);
- assertEquals(locBR.getDisplayCountry(locBR), __);
-
- Locale locCH = new Locale("it", "CH");
- assertEquals(locCH.getDisplayCountry(), __);
- assertEquals(locCH.getDisplayCountry(locCH), __);
- assertEquals(locCH.getDisplayCountry(new Locale("de", "CH")), __);
- }
-
- @Koan
- public void formatCurrency() {
- float someAmount = 442.23f; // Don't use floats for money in real life. Really. It's a bad idea.
- Locale locBR = new Locale("pt", "BR");
- NumberFormat nf = NumberFormat.getCurrencyInstance(locBR);
- assertEquals(nf.format(someAmount), __);
- }
-}
diff --git a/koans/src/intermediate/AboutRegularExpressions.java b/koans/src/intermediate/AboutRegularExpressions.java
deleted file mode 100644
index d5999645..00000000
--- a/koans/src/intermediate/AboutRegularExpressions.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package intermediate;
-
-
-import com.sandwich.koan.Koan;
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import static com.sandwich.koan.constant.KoanConstants.__;
-import static com.sandwich.util.Assert.assertEquals;
-
-
-public class AboutRegularExpressions {
-
- @Koan
- public void basicMatching() {
- Pattern p = Pattern.compile("xyz");
- Matcher m = p.matcher("xyzxxxxyz");
- // index 012345678
- assertEquals(m.find(), __);
- assertEquals(m.start(), __);
- assertEquals(m.find(), __);
- assertEquals(m.start(), __);
- assertEquals(m.find(), __);
- }
-
- @Koan
- public void extendedMatching() {
- Pattern p = Pattern.compile("x.z");
- Matcher m = p.matcher("xyz u x z u xfz");
- // index 012345678901234
- assertEquals(m.find(), __);
- assertEquals(m.start(), __);
- assertEquals(m.find(), __);
- assertEquals(m.start(), __);
- assertEquals(m.find(), __);
- assertEquals(m.start(), __);
- }
-
- @Koan
- public void escapingMetaCharacters() {
- Pattern p = Pattern.compile("end\\.");
- Matcher m = p.matcher("begin. end.");
- // index 01234567890
- assertEquals(m.find(), __);
- assertEquals(m.start(), __);
- }
-
- @Koan
- public void splittingStrings() {
- String csvDataLine = "1,name,description";
- String[] data = csvDataLine.split(","); // you can use any regex here
- assertEquals(data[0], __);
- assertEquals(data[1], __);
- assertEquals(data[2], __);
- }
-}
diff --git a/koans/src/java7/AboutDiamondOperator.java b/koans/src/java7/AboutDiamondOperator.java
deleted file mode 100644
index a9c32ac0..00000000
--- a/koans/src/java7/AboutDiamondOperator.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package java7;
-
-import com.sandwich.koan.Koan;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import static com.sandwich.koan.constant.KoanConstants.__;
-import static com.sandwich.util.Assert.assertEquals;
-
-public class AboutDiamondOperator {
-
- @Koan
- public void diamondOperator() {
- String[] animals = {"Dog", "Cat", "Tiger", "Elephant", "Zebra"};
- //Generic type of array list inferred - empty <> operator
- List animalsList = new ArrayList<>(Arrays.asList(animals));
- assertEquals(animalsList, __);
- }
-
- @Koan
- public void diamondOperatorInMethodCall() {
- String[] animals = {"Dog", "Cat", "Tiger", "Elephant", "Zebra"};
- //type of new ArrayList<>() inferred from method parameter
- List animalsList = fill(new ArrayList<>());
- assertEquals(animalsList, __);
- }
-
- private List fill(List list) {
- String[] animals = {"Dog", "Cat", "Tiger", "Elephant", "Zebra"};
- list.addAll(Arrays.asList(animals));
- return list;
- }
-
-}
diff --git a/koans/src/java7/AboutJava7LiteralsEnhancements.java b/koans/src/java7/AboutJava7LiteralsEnhancements.java
deleted file mode 100644
index 4d8e2a38..00000000
--- a/koans/src/java7/AboutJava7LiteralsEnhancements.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package java7;
-
-import com.sandwich.koan.Koan;
-
-import static com.sandwich.koan.constant.KoanConstants.__;
-import static com.sandwich.util.Assert.assertEquals;
-
-public class AboutJava7LiteralsEnhancements {
-
- @Koan
- public void binaryLiterals() {
- //binary literals are marked with 0b prefix
- short binaryLiteral = 0b1111;
- assertEquals(binaryLiteral, __);
- }
-
- @Koan
- public void binaryLiteralsWithUnderscores() {
- //literals can use underscores for improved readability
- short binaryLiteral = 0b1111_1111;
- assertEquals(binaryLiteral, __);
- }
-
- @Koan
- public void numericLiteralsWithUnderscores() {
- long literal = 111_111_111L;
- //notice capital "B" - a valid binary literal prefix
- short multiplier = 0B1_000;
- assertEquals(literal * multiplier, __);
- }
-
- @Koan
- public void negativeBinaryLiteral() {
- int negativeBinaryLiteral = 0b1111_1111_1111_1111_1111_1111_1111_1100 / 4;
- assertEquals(negativeBinaryLiteral, __);
- }
-
- @Koan
- public void binaryLiteralsWithBitwiseOperator() {
- int binaryLiteral = ~0b1111_1111;
- assertEquals(binaryLiteral, __);
- }
-
-}
diff --git a/koans/src/java7/AboutRequireNotNull.java b/koans/src/java7/AboutRequireNotNull.java
deleted file mode 100644
index de4b017f..00000000
--- a/koans/src/java7/AboutRequireNotNull.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package java7;
-
-import com.sandwich.koan.Koan;
-
-import java.util.Objects;
-
-import static com.sandwich.koan.constant.KoanConstants.__;
-import static com.sandwich.util.Assert.assertEquals;
-
-public class AboutRequireNotNull {
-
- @Koan
- public void failArgumentValidationWithRequireNotNull() {
- // This koan demonstrates the use of Objects.requireNotNull
- // in place of traditional argument validation using exceptions
- String s = "";
- try {
- s += validateUsingRequireNotNull(null);
- } catch (NullPointerException ex) {
- s = "caught a NullPointerException";
- }
- assertEquals(s, __);
- }
-
- @Koan
- public void passArgumentValidationWithRequireNotNull() {
- // This koan demonstrates the use of Objects.requireNotNull
- // in place of traditional argument validation using exceptions
- String s = "";
- try {
- s += validateUsingRequireNotNull("valid");
- } catch (NullPointerException ex) {
- s = "caught a NullPointerException";
- }
- assertEquals(s, __);
- }
-
- private int validateUsingRequireNotNull(String str) {
- // If you're only concerned with null values requireNotNull
- // is concise and the point of the NullPointerException it
- // throws is clear, though you can optionally provide a
- // description as well
- return Objects.requireNonNull(str).length();
- }
-
-}
diff --git a/koans/src/java7/AboutStringsInSwitch.java b/koans/src/java7/AboutStringsInSwitch.java
deleted file mode 100644
index 31a79c6f..00000000
--- a/koans/src/java7/AboutStringsInSwitch.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package java7;
-
-import com.sandwich.koan.Koan;
-
-import static com.sandwich.koan.constant.KoanConstants.__;
-import static com.sandwich.util.Assert.assertEquals;
-
-public class AboutStringsInSwitch {
-
- @Koan
- public void stringsInSwitchStatement() {
- String[] animals = {"Dog", "Cat", "Tiger", "Elephant", "Zebra"};
- String dangerous = null;
- String notDangerous = null;
- for (String animal : animals) {
- switch (animal) {
- case "Tiger":
- dangerous = animal;
- case "Dog":
- case "Cat":
- case "Elephant":
- case "Zebra":
- notDangerous = animal;
- }
- }
- assertEquals(notDangerous, __);
- assertEquals(dangerous, __);
- }
-
-}
diff --git a/koans/src/java7/AboutTryWithResources.java b/koans/src/java7/AboutTryWithResources.java
deleted file mode 100644
index 4934b1e1..00000000
--- a/koans/src/java7/AboutTryWithResources.java
+++ /dev/null
@@ -1,109 +0,0 @@
-package java7;
-
-import com.sandwich.koan.Koan;
-
-import java.io.*;
-
-import static com.sandwich.koan.constant.KoanConstants.__;
-import static com.sandwich.util.Assert.assertEquals;
-
-public class AboutTryWithResources {
-
- class AutoClosableResource implements AutoCloseable {
- public void foo() throws WorkException {
- throw new WorkException("Exception thrown while working");
- }
-
- public void close() throws CloseException {
- throw new CloseException("Exception thrown while closing");
- }
- }
-
- class WorkException extends Exception {
- public WorkException(String message) {
- super(message);
- }
- }
-
- class CloseException extends Exception {
- public CloseException(String message) {
- super(message);
- }
- }
-
- @Koan
- public void lookMaNoClose() {
- String str = "first line"
- + System.lineSeparator()
- + "second line";
- InputStream is = new ByteArrayInputStream(str.getBytes());
- String line;
- /* BufferedReader implementing @see java.lang.AutoCloseable interface */
- try (BufferedReader br =
- new BufferedReader(
- new InputStreamReader(is))) {
- line = br.readLine();
- //br guaranteed to be closed
- } catch (IOException e) {
- line = "error";
- }
- assertEquals(line, __);
- }
-
- @Koan
- public void lookMaNoCloseWithException() throws IOException {
- String line = "no need to close readers";
- try (BufferedReader br =
- new BufferedReader(
- new FileReader("I do not exist!"))) {
- line = br.readLine();
- } catch (FileNotFoundException e) {
- line = "no more leaking!";
- }
- assertEquals(line, __);
- }
-
- @Koan
- public void lookMaNoCloseWithMultipleResources() throws IOException {
- String str = "first line"
- + System.lineSeparator()
- + "second line";
- InputStream is = new ByteArrayInputStream(str.getBytes());
- String line;
- //multiple resources in the same try declaration
- try (BufferedReader br =
- new BufferedReader(
- new FileReader("I do not exist!"));
- BufferedReader brFromString =
- new BufferedReader(
- new InputStreamReader(is))
- ) {
- line = br.readLine();
- line += brFromString.readLine();
- } catch (IOException e) {
- line = "error";
- }
- assertEquals(line, __);
- }
-
- @Koan
- public void supressException() {
- String message = "";
- try {
- bar();
- } catch (WorkException e) {
- message += e.getMessage() + " " + e.getSuppressed()[0].getMessage();
- } catch (CloseException e) {
- message += e.getMessage();
- }
- assertEquals(message, __);
- }
-
-
- public void bar() throws CloseException, WorkException {
- try (AutoClosableResource autoClosableResource =
- new AutoClosableResource()) {
- autoClosableResource.foo();
- }
- }
-}
\ No newline at end of file
diff --git a/koans/src/java8/AboutBase64.java b/koans/src/java8/AboutBase64.java
deleted file mode 100644
index ed1235e8..00000000
--- a/koans/src/java8/AboutBase64.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package java8;
-
-import com.sandwich.koan.Koan;
-
-import java.util.Base64;
-import java.io.UnsupportedEncodingException;
-
-import static com.sandwich.koan.constant.KoanConstants.__;
-import static com.sandwich.util.Assert.assertEquals;
-
-public class AboutBase64 {
-
- private final String plainText = "lorem ipsum";
- private final String encodedText = "bG9yZW0gaXBzdW0=";
-
- @Koan
- public void base64Encoding() {
- try {
- // Encode the plainText
- // This uses the basic Base64 encoding scheme but there are corresponding
- // getMimeEncoder and getUrlEncoder methods available if you require a
- // different format/Base64 Alphabet
- assertEquals(encodedText, Base64.getEncoder().encodeToString(__.getBytes("utf-8")));
- } catch (UnsupportedEncodingException ex) {}
- }
-
- @Koan
- public void base64Decoding() {
- // Decode the Base64 encodedText
- // This uses the basic Base64 decoding scheme but there are corresponding
- // getMimeDecoder and getUrlDecoder methods available if you require a
- // different format/Base64 Alphabet
- byte[] decodedBytes = Base64.getDecoder().decode(__);
- try {
- String decodedText = new String(decodedBytes, "utf-8");
- assertEquals(plainText, decodedText);
- } catch (UnsupportedEncodingException ex) {}
- }
-
-}
diff --git a/koans/src/java8/AboutDefaultMethods.java b/koans/src/java8/AboutDefaultMethods.java
deleted file mode 100644
index d2a5c994..00000000
--- a/koans/src/java8/AboutDefaultMethods.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package java8;
-
-import com.sandwich.koan.Koan;
-
-import static com.sandwich.koan.constant.KoanConstants.__;
-import static com.sandwich.util.Assert.assertEquals;
-
-public class AboutDefaultMethods {
-
- @Koan
- public void interfaceDefaultMethod() {
- StringUtil stringUtil = new StringUtil() {
- @Override
- public String reverse(String s) {
- return new StringBuilder(s).reverse().toString();
- }
- };
- String capitalizedReversed = stringUtil.capitalize(
- stringUtil.reverse("gnirut"));
- assertEquals(capitalizedReversed, __);
- }
-
- @Koan
- public void interfaceStaticMethod() {
- assertEquals(StringUtil.enclose("me"), __);
- }
-
- interface StringUtil {
-
- //static method in interface
- static String enclose(String in) {
- return "[" + in + "]";
- }
-
- String reverse(String s);
-
- //interface can contain non-abstract method implementations marked by "default" keyword
- default String capitalize(String s) {
- return s.toUpperCase();
- }
-
- default String capitalizeFirst(String s) {
- return s.substring(0, 1).toUpperCase() + s.substring(1);
- }
- }
-
-}
diff --git a/koans/src/java8/AboutLambdas.java b/koans/src/java8/AboutLambdas.java
deleted file mode 100644
index 8cab569b..00000000
--- a/koans/src/java8/AboutLambdas.java
+++ /dev/null
@@ -1,90 +0,0 @@
-package java8;
-
-import com.sandwich.koan.Koan;
-
-import java.util.function.Function;
-
-import static com.sandwich.koan.constant.KoanConstants.__;
-import static com.sandwich.util.Assert.assertEquals;
-
-public class AboutLambdas {
-
- interface Caps {
- public String capitalize(String name);
- }
-
- String fieldFoo = "Lambdas";
-
- @Override
- public String toString() {
- return "CAPS";
- }
-
- static String str = "";
-
- //lambda has access to "this"
- Caps thisLambdaField = s -> this.toString();
- //lambda has access to object methods
- Caps toStringLambdaField = s -> toString();
-
- @Koan
- public void verySimpleLambda() throws InterruptedException {
- Runnable r8 = () -> str = "changed in lambda";
- r8.run();
- assertEquals(str, __);
- }
-
- @Koan
- public void simpleLambda() {
- Caps caps = (String n) -> {
- return n.toUpperCase();
- };
- String capitalized = caps.capitalize("James");
- assertEquals(capitalized, __);
- }
-
- @Koan
- public void simpleSuccinctLambda() {
- //parameter type can be omitted,
- //code block braces {} and return statement can be omitted for single statement lambda
- //parameter parenthesis can be omitted for single parameter lambda
- Caps caps = s -> s.toUpperCase();
- String capitalized = caps.capitalize("Arthur");
- assertEquals(capitalized, __);
- }
-
- @Koan
- public void lambdaField() {
- assertEquals(thisLambdaField.capitalize(""), __);
- }
-
- @Koan
- public void lambdaField2() {
- assertEquals(toStringLambdaField.capitalize(""), __);
- }
-
- @Koan
- public void effectivelyFinal() {
- //final can be omitted like this:
- /* final */
- String effectivelyFinal = "I'm effectively final";
- Caps caps = s -> effectivelyFinal.toUpperCase();
- assertEquals(caps.capitalize(effectivelyFinal), __);
- }
-
- @Koan
- public void methodReference() {
- Caps caps = String::toUpperCase;
- String capitalized = caps.capitalize("Gosling");
- assertEquals(capitalized, __);
- }
-
- @Koan
- public void thisIsSurroundingClass() {
- //"this" in lambda points to surrounding class
- Function foo = s -> s + this.fieldFoo + s;
- assertEquals(foo.apply("|"), __);
- }
-
-}
-
diff --git a/koans/src/java8/AboutLocalTime.java b/koans/src/java8/AboutLocalTime.java
deleted file mode 100644
index c99e1dc1..00000000
--- a/koans/src/java8/AboutLocalTime.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package java8;
-
-import com.sandwich.koan.Koan;
-
-import java.time.LocalTime;
-import java.time.temporal.ChronoUnit;
-
-import static com.sandwich.koan.constant.KoanConstants.__;
-import static com.sandwich.util.Assert.assertEquals;
-
-public class AboutLocalTime {
-
- @Koan
- public void localTime() {
- LocalTime t1 = LocalTime.of(7, 30);
- assertEquals(t1, LocalTime.parse(__));
- }
-
- @Koan
- public void localTimeMinus() {
- LocalTime t1 = LocalTime.parse("10:30");
- LocalTime t2 = t1.minus(2, ChronoUnit.HOURS);
- assertEquals(t2, LocalTime.parse(__));
- }
-
-}
diff --git a/koans/src/java8/AboutMultipleInheritance.java b/koans/src/java8/AboutMultipleInheritance.java
deleted file mode 100644
index 40a54c56..00000000
--- a/koans/src/java8/AboutMultipleInheritance.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package java8;
-
-import com.sandwich.koan.Koan;
-
-import static com.sandwich.koan.constant.KoanConstants.__;
-import static com.sandwich.util.Assert.assertEquals;
-
-public class AboutMultipleInheritance {
-
- interface Human {
- default String sound() {
- return "hello";
- }
- }
-
- interface Bull {
- default String sound() {
- return "moo";
- }
- }
-
- class Minotaur implements Human, Bull {
- //both interfaces implement same default method
- //has to be overridden
- @Override
- public String sound() {
- return Bull.super.sound();
- }
- }
-
- @Koan
- public void multipleInheritance() {
- Minotaur minotaur = new Minotaur();
- assertEquals(minotaur.sound(), __);
- }
-
-}
diff --git a/koans/src/java8/AboutOptional.java b/koans/src/java8/AboutOptional.java
deleted file mode 100644
index d2ba6b53..00000000
--- a/koans/src/java8/AboutOptional.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package java8;
-
-import com.sandwich.koan.Koan;
-
-import java.util.Optional;
-
-import static com.sandwich.koan.constant.KoanConstants.__;
-import static com.sandwich.util.Assert.assertEquals;
-
-public class AboutOptional {
-
- boolean optionalIsPresentField = false;
-
- @Koan
- public void isPresent() {
- boolean optionalIsPresent = false;
- Optional value = notPresent();
- if (value.isPresent()) {
- optionalIsPresent = true;
- }
- assertEquals(optionalIsPresent, __);
- }
-
- @Koan
- public void ifPresentLambda() {
- Optional value = notPresent();
- value.ifPresent(x -> optionalIsPresentField = true);
- assertEquals(optionalIsPresentField, __);
- }
-
- //use optional on api to signal that value is optional
- public Optional notPresent() {
- return Optional.empty();
- }
-
- private Optional present() {
- return Optional.of("is present");
- }
-}
diff --git a/koans/src/java8/AboutStreams.java b/koans/src/java8/AboutStreams.java
deleted file mode 100644
index 42e7b2db..00000000
--- a/koans/src/java8/AboutStreams.java
+++ /dev/null
@@ -1,135 +0,0 @@
-package java8;
-
-import com.sandwich.koan.Koan;
-
-import java.util.*;
-import java.util.stream.Collectors;
-import java.util.stream.IntStream;
-import java.util.stream.Stream;
-
-import static com.sandwich.koan.constant.KoanConstants.__;
-import static com.sandwich.util.Assert.assertEquals;
-
-public class AboutStreams {
-
- String str = "";
-
- List places = Arrays.asList("Belgrade", "Zagreb", "Sarajevo", "Skopje", "Ljubljana", "Podgorica");
-
- @Koan
- public void simpleCount() {
- long count = places.stream().count();
- assertEquals(count, __);
- }
-
- @Koan
- public void filteredCount() {
- long count = places.stream()
- .filter(s -> s.startsWith("S"))
- .count();
- assertEquals(count, __);
- }
-
- @Koan
- public void max() {
- String longest = places.stream()
- .max(Comparator.comparing(cityName -> cityName.length()))
- .get();
- assertEquals(longest, __);
- }
-
- @Koan
- public void min() {
- String shortest = places.stream()
- .min(Comparator.comparing(cityName -> cityName.length()))
- .get();
- assertEquals(shortest, __);
- }
-
- @Koan
- public void reduce() {
- String join = places.stream()
- .reduce("", String::concat);
- assertEquals(join, __);
- }
-
- @Koan
- public void reduceWithoutStarterReturnsOptional() {
- Optional join = places.stream()
- .reduce(String::concat);
- assertEquals(join.get(), __);
- }
-
- @Koan
- public void join() {
- String join = places.stream()
- .reduce((accumulated, cityName) -> accumulated + "\", \"" + cityName)
- .get();
- assertEquals(join, __);
- }
-
- @Koan
- public void reduceWithBinaryOperator() {
- String join = places.stream()
- .reduce("", String::concat);
- assertEquals(join, __);
- }
-
- @Koan
- public void stringJoin() {
- String join = places.stream()
- .collect(Collectors.joining("\", \""));
- assertEquals(join, __);
- }
-
- @Koan
- public void mapReduce() {
- OptionalDouble averageLengthOptional = places.stream()
- .mapToInt(String::length)
- .average();
- double averageLength = Math.round(averageLengthOptional.getAsDouble());
- assertEquals(averageLength, __);
- }
-
- @Koan
- public void parallelMapReduce() {
- int lengthSum = places.parallelStream()
- .mapToInt(String::length)
- .sum();
- assertEquals(lengthSum, __);
- }
-
- @Koan
- public void limitSkip() {
- int lengthSum_Limit_3_Skip_1 = places.stream()
- .mapToInt(String::length)
- .limit(3)
- .skip(1)
- .sum();
- assertEquals(lengthSum_Limit_3_Skip_1, __);
- }
-
- @Koan
- public void lazyEvaluation() {
- Stream stream = places.stream()
- .filter(s -> {
- str = "hello";
- return s.startsWith("S");
- });
- assertEquals(str, __);
- }
-
- @Koan
- public void sumRange() {
- int sum = IntStream.range(1, 4).sum();
- assertEquals(sum, __);
- }
-
- @Koan
- public void rangeToList() {
- List range = IntStream.range(1, 4)
- .boxed()
- .collect(Collectors.toList());
- assertEquals(range, __);
- }
-}