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
public boolean playerWon(String boardAsString, char player) { | |
char[] board = boardAsString.toCharArray(); | |
Stream<Stream<Integer>> winningCombinations = Stream.of( | |
// rows | |
Stream.of(0, 1, 2), | |
Stream.of(3, 4, 5), | |
Stream.of(6, 7, 8), | |
// columns | |
Stream.of(0, 3, 6), | |
Stream.of(1, 4, 7), |
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
// Not what I'd call good readable code, but it amuses me ;D | |
private boolean playerWon(char player, char[] board) { | |
return of( | |
// rows | |
of(0, 1, 2), of(3, 4, 5), of(6, 7, 8), | |
// columns | |
of(0, 3, 6), of(1, 4, 7), of(2, 5, 8), | |
// diagonals | |
of(0, 4, 8),of(2, 4, 6) |
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 java.io.BufferedReader; | |
import java.io.IOException; | |
import java.io.PrintWriter; | |
public class ConsoleUI { | |
private PrintWriter writer; | |
private BufferedReader reader; | |
public ConsoleUI(PrintWriter out, BufferedReader reader) { |
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
@Test | |
public void testReadXml() { | |
try { | |
ApplicationTargets applicationTargetList = roleXmlReader.readXml(); | |
if (applicationTargetList != null) { | |
if (applicationTargetList.getApplicationTargetList() == null | |
&& applicationTargetList.getApplicationTargetList() | |
.size() == 0) { | |
fail("Error while reading XML file"); | |
} |
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 Test.Hspec.QuickCheck | |
class RomanDigit rd where | |
toArabic :: rd -> Int | |
data Ones = I | II | III | |
instance RomanDigit Ones where | |
toArabic I = 1 | |
toArabic II = 2 | |
toArabic III =3 |
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 Test.Hspec | |
import Data.List | |
main = hspec $ do | |
describe "set" $ do | |
it "one card is not a set" $ do | |
containsset [(Rectangle, Full, Blue, One)] `shouldBe` False | |
it "all One Full Blue is a set" $ do | |
containsset [(Rectangle, Full, Blue, One), (Circle, Full, Blue, One), (Triangle, Full, Blue, One)] `shouldBe` True | |
it "all One Blue Rectangle is a set" $ do |
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
function isSelectableZone(drawObject) { | |
return !drawObject.selectionZone.unselectable | |
} | |
function isThereAtLeastOneSelectableZone(drawObjects) { | |
return lambdas.any(drawObjects, isSelectableZone) | |
} | |
// I personally use lodash for javascript; so the above line would have been | |
// return lodash.any(drawObjects, isSelectableZone) |
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
it('contains the path of the pdf', function() { | |
var submitToQueueSpy = sinon.spy(); | |
var langBuilder = new LangBuilder(submitToQueueSpy, pdfUtility); | |
langBuilder.buildLang(parentEntityKey, pdPath); | |
var expectedPayload = {originalFilepath: pdPath}; | |
sinon.assert.calledWith(submitToQueueSpy, sinon.match(expectedPayload)) | |
}) |
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
@ActionMapping(params = "action=doFormAction") | |
public void doAction(@ModelAttribute AccountBean accountBean, HttpRequest request, HttpResponse response) throws IOException { | |
CreationResponse creationResponse = new HttpCreationResponse(response); | |
accountService.createAccount(accountBean, creationResponse); | |
} |
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
@ActionMapping(params = "action=doFormAction") | |
public void doAction(@ModelAttribute AccountBean accountBean, HttpRequest request, | |
HttpResponse response) throws IOException { | |
boolean compteCree = false; | |
try { | |
compteCree = accountService.createAccount(accountBean); | |
} catch (TechnicalException e) { |