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
// Game | |
public class Game { | |
private final Grid grid; | |
private final PlacementError placementError; | |
private Mark playingMark; | |
public Game(PlacementError placementError) { | |
grid = new Grid(); | |
playingMark = Mark.x(); |
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
// Inefficient, but interesting "string to title case" implementation using Linq. | |
"some text" | |
.Split(' ') | |
.Select(word => char.ToUpper(word[0]) + word.Remove(0, 1).ToLower()) | |
.Aggregate((result, nextValue) => result + ' ' + nextValue); |
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
// The first thing I did was generalize the "orders have free shipping to Australia" concept | |
// to "orders adjust their shipping charges in some way". | |
// I wouldn't want Order to get cluttered with lots of shipping rules. | |
// Instead of doing this in constructor, it could instead have a method like | |
// order.adjustShipping(shippingAdjustments). | |
@Test | |
public void whenCreatingAnOrder_AdjustsShippingCharges() { | |
ShippingAdjustments mockedShippingAdjustments = mock(ShippingAdjustments.class); | |
Country mockedCountry = mock(Country.class); | |
Order order = new Order(mockedCountry, mockedShippingAdjustments, other, parameters); |
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
'a' asJQuery each: [ :index :value | | |
value asJQuery on: 'click' do: [ :event | | |
event preventDefault. | |
window alert: 'I am link #' , index | |
] | |
] | |
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
// Does it matter? | |
// Testing turnRight() this way tests the behavior in terms of | |
// another method on the same object. | |
// Possible problems: | |
// - We need to implement the other method first. | |
// - We need to call another method in order to verify that turnRight behaves correctly. | |
@Test | |
public void WhenTurningRight_IfPlaced_ShouldMoveInDirectionRightOfStartWhenMoved() { |
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
// Original implementation | |
public class ConsoleCommandSource implements CommandSource { | |
private final Console console; | |
private final TextParser textParser; | |
public ConsoleCommandSource(final Console console, final TextParser textParser) { | |
this.textParser = textParser; | |
this.console = console; | |
} |
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 interface MovesReceiver { | |
void path(final MoveCount moveCount, | |
final Consumer<PathDirection> pathDirectionConsumer, | |
final Consumer<CollisionRule> collisionRuleConsumer); | |
void step(final Consumer<StepDirection> stepDirectionConsumer, | |
final Consumer<CollisionRule> collisionRuleConsumer); | |
} |
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 interface MovesReceiver { | |
PathBuilder path(final MoveCount moveCount); | |
StepBuilder step(); | |
} | |
public class MoveCount { | |
private final int number; |
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
#include <iostream> | |
using namespace std; | |
int main () | |
{ | |
unsigned long previousNthFibNumber = 0, | |
nthFibNumber = 1, | |
sum = 0, | |
numEntered; |
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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using Microsoft.VisualStudio.TestTools.UnitTesting; | |
namespace ScratchPadTest | |
{ | |
[TestClass] | |
public class BowlingTest | |
{ |
NewerOlder