Skip to content

Instantly share code, notes, and snippets.

// TotalCalculator.js
function TotalCalculator() {
}
TotalCalculator.prototype.calculate = function(quantity, price) {
var _quantity = parseInt(quantity);
if (isNaN(_quantity))
return 'N/A';
var _price = parseInt(price.replace('$', ''));
using System;
using Machine.Specifications;
using Given = Machine.Specifications.Establish;
using When = Machine.Specifications.Because;
using Then = Machine.Specifications.It;
namespace TryMSpec {
public class TicketCalculator{
private decimal _ticket_price = 11m;
public void StartPurchase(int runtime, DayOfWeek day, bool isParquet, bool is3D) {}
@adomokos
adomokos / core_test.clj
Created May 15, 2015 18:53
Solving the Roman Numeral Kata in Clojure
(ns roman-numerals.core-test
(:require [clojure.test :refer :all]))
(def mapping {
0 ""
1 "I"
4 "IV"
5 "V"
9 "IX"
10 "X"
@adomokos
adomokos / string_calculator_spec.rb
Last active August 29, 2015 14:12
String Calculator Kata in Ruby - using enumerable methods
# Solving the String Calculator Kata
# http://osherove.com/tdd-kata-1/
class StringCalculator
def self.add(numbers)
return 0 if numbers.empty?
numbers.split(",").map(&:to_i).reduce(:+)
#splitted_array = numbers.split(",")
@adomokos
adomokos / group_by_spec.rb
Created March 5, 2014 04:12
Recognizing Ruby's group_by in the imperative code
class Location
attr_reader :city, :user
def initialize(city, user)
@city = city
@user = user
end
end
class User
attr_reader :name