Skip to content

Instantly share code, notes, and snippets.

@rkie
rkie / RomanNumeral.kt
Created April 2, 2023 14:28
Used to demonstrate test driven refactoring in https://failedtofunction.com/test-driven-refactoring/
package com.failedtofunction.examples.numerals
class RomanNumeral {
private val value: Int
private val representation: String
private constructor(value: Int, representation: String) {
this.value = value
this.representation = representation
@rkie
rkie / RomanNumeralExtensions.kt
Created March 6, 2023 13:53
Examples from How to Start Test Driven Development on failedtofunction.com
package com.failedtofunction.examples.numerals
fun Char.romanNumeralValue(): Int =
when (this) {
'I' -> 1
'V' -> 5
'X' -> 10
'L' -> 50
'C' -> 100
'D' -> 500
@rkie
rkie / guessing_game.py
Last active June 11, 2018 20:02
A simple program for a guessing game I wrote with my children to begin teaching them to write code. See my blog post about the experience at http://failedtofunction.com/coding-with-children/
from random import randint
import re
def ask_for_a_number_with(question):
number = input(question)
while (re.match(r'^[0-9]+$', number) == None):
print('That is not a valid number. Try again.')
number = input(question)
return int(number)
@rkie
rkie / Steps.java
Created January 27, 2018 16:55
Cucumber date format workaround
package com.failedtofunction.example.cumcumberdates;
import static org.junit.Assert.assertEquals;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import com.failedtofunction.example.cucumberdates.DateUtilities;
import com.failedtofunction.example.cucumberdates.Person;