This file contains 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
return Win() | |
|| Advantage() | |
|| ScoreNormal() | |
|| person2.ScoreOpponentHasntScored(person1) | |
|| person1.ScoreOpponentHasntScored(person2) | |
|| ScoreTie(); |
This file contains 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
return Win() | |
?? Advantage() | |
?? ScoreNormal() | |
?? person2.ScoreOpponentHasntScored(person1) | |
?? person1.ScoreOpponentHasntScored(person2) | |
?? ScoreTie(); |
This file contains 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
string result = null; | |
result = result.DoIfNull(Win); | |
result = result.DoIfNull(Advantage); | |
result = result.DoIfNull(ScoreNormal); | |
result = result.DoIfNull(ScorePerson1); | |
result = result.DoIfNull(ScorePerson2); | |
result = result.DoIfNull(ScoreTie); | |
return result; | |
public static T DoIfNull<T>(this T t, Func<T> f ) |
This file contains 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
private IEnumerable<string> ProcessScores() | |
{ | |
yield return Win(); | |
yield return Advantage(); | |
yield return ScoreNormal(); | |
yield return person2.ScoreOpponentHasntScored(person1); | |
yield return person1.ScoreOpponentHasntScored(person2); | |
yield return ScoreTie(); | |
throw new Exception("Unreachable code was executed"); | |
} |
This file contains 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
return new Func<string>[] | |
{ | |
Win, | |
Advantage, | |
ScoreNormal, | |
ScorePerson1, | |
ScorePerson2, | |
ScoreTie | |
}.FirstNonNull(); |
This file contains 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
public string Advantage(string previousResult) | |
{ | |
if (previousResult != null) | |
{ | |
return previousResult; | |
} |
This file contains 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
string result; | |
result = Win(); | |
result = Advantage(result); | |
result = ScoreNormal(result); | |
result = ScorePerson1(result); | |
result = ScorePerson2(result); | |
result = ScoreTie(result); | |
return result; |
This file contains 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
string result; | |
result = Win(); | |
if (result != null) | |
{ | |
return result; | |
} | |
result = Advantage(); | |
if (result != null) | |
{ | |
return result; |
This file contains 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 com.spun.triangles.test; | |
import static org.junit.Assert.assertEquals; | |
import java.util.Random; | |
import org.junit.Test; | |
/** | |
* Theory based kata |
This file contains 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 org.xp2015.smells; | |
import java.math.BigDecimal; | |
import java.util.ArrayList; | |
import java.util.HashMap; | |
import java.util.Iterator; | |
import java.util.List; | |
import java.util.Map; | |
import org.apache.commons.lang.StringUtils; |