diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..64f25ba Binary files /dev/null and b/.DS_Store differ diff --git a/numerals/.DS_Store b/numerals/.DS_Store new file mode 100644 index 0000000..890ce1a Binary files /dev/null and b/numerals/.DS_Store differ diff --git a/numerals/Gemfile b/numerals/Gemfile index 5ab4adc..e69de29 100644 --- a/numerals/Gemfile +++ b/numerals/Gemfile @@ -1,5 +0,0 @@ -source :rubygems -group :test do -gem 'cucumber', '2.4.0' -gem 'rspec-expectations', '2.7.0' -end diff --git a/numerals/Main.class b/numerals/Main.class deleted file mode 100644 index 94a3512..0000000 Binary files a/numerals/Main.class and /dev/null differ diff --git a/numerals/Main.java b/numerals/Main.java index d581a79..2d87cc9 100644 --- a/numerals/Main.java +++ b/numerals/Main.java @@ -1,12 +1,38 @@ public class Main { + public static String[] number_to_words = { + "een", + "twee", + "drie", + "vier", + "vijf", + "zes", + "zeven", + "acht", + "negen", + "tien", + "elf", + "twaalf", + "dertien", + "veertien", + "vijftien", + "zestien", + "zeventien", + "achttien", + "negentien", + "twintig" + }; + public static void main(String[] args) { + String input = args[0].replace("\n", "");; + if(input.contains("-")){ + String[] numbers = input.split("-"); + int result = Integer.parseInt(numbers[0]); - String input = args[0]; - if(input.contains("^")){ - String[] numbers = input.split("^"); - int a = Integer.parseInt(numbers[0]); - System.out.print(a * a); + for (int i = 1; i < numbers.length; i++) { + result = result - Integer.parseInt(numbers[i]); + } + System.out.print(number_to_words[result - 1]); } } } diff --git a/numerals/features/.DS_Store b/numerals/features/.DS_Store new file mode 100644 index 0000000..0e5e76b Binary files /dev/null and b/numerals/features/.DS_Store differ diff --git a/numerals/features/aukebakker.feature b/numerals/features/aukebakker.feature deleted file mode 100644 index fcd8148..0000000 --- a/numerals/features/aukebakker.feature +++ /dev/null @@ -1,11 +0,0 @@ -Feature: Numerals should be exponentional. - - Scenario: Show the exponant of a 2^2. - Given the input "2^2" - When the converter is run - Then the output should be "vier" - - Scenario: Show the exponant of 7^3. - Given the input "7^3" - When the converter is run - Then the output should be "driehonderddrieenveertig" diff --git a/numerals/features/binary.feature b/numerals/features/binary.feature deleted file mode 100644 index 23633b4..0000000 --- a/numerals/features/binary.feature +++ /dev/null @@ -1,27 +0,0 @@ -Feature: numerals 1-20 should be translated. -Scenario Outline: Display uncomplicated numbers as binary -When the input is -Then the output should be - - Examples: - | number | binary | - | 1 | 1 | - | 2 | 10 | - | 3 | 11 | - | 4 | 100 | - | 5 | 101 | - | 6 | 110 | - | 7 | 111 | - | 8 | 1000 | - | 9 | 1001 | - |10 | 1010 | - |11 | 1011 | - |12 | 1100 | - |13 | 1101 | - |14 | 1110 | - |15 | 1111 | - |16 | 10000 | - |17 | 10001 | - |18 | 10010 | - |19 | 10011 | - |20 | 10100 | \ No newline at end of file diff --git a/numerals/features/daniel-multiply.feature b/numerals/features/daniel-multiply.feature deleted file mode 100644 index 1a6f524..0000000 --- a/numerals/features/daniel-multiply.feature +++ /dev/null @@ -1,11 +0,0 @@ -Feature: Numerals should be multipliable. - -Scenario: Show the multiplication of two numbers. -Given the input "2*2" -When the converter is run -Then the output should be "vier" - -Scenario: Show that the multiplication of two numbers is transitive. -Given the input "2*2*2" -When the converter is run -Then the output should be "8" \ No newline at end of file diff --git a/numerals/features/joopvriezen.feature b/numerals/features/joopvriezen.feature deleted file mode 100644 index f73b47f..0000000 --- a/numerals/features/joopvriezen.feature +++ /dev/null @@ -1,12 +0,0 @@ -Feature: Adding numbers - - Scenario: Add up two numbers. - Given the input "15" - When 10 is added - Then the output should be "twentyfive" - - Scenario: Show that adding multiple times also works - Given the input "10" - When 20 is added - And 20 is added again - Then the output should be "fifty" \ No newline at end of file diff --git a/numerals/features/koen.feature b/numerals/features/koen.feature deleted file mode 100644 index a496bdb..0000000 --- a/numerals/features/koen.feature +++ /dev/null @@ -1,10 +0,0 @@ -Feature: Square root - Scenario: square root 25 - Given the input "sqrt(25)" - When the calculator is run - Then the output should be "5" - - Scenario: square root 100 - Given the input "sqrt(100)" - When the calculator is run - Then the output should be "10" \ No newline at end of file diff --git a/numerals/features/numerals.feature b/numerals/features/numerals.feature deleted file mode 100644 index d7131f8..0000000 --- a/numerals/features/numerals.feature +++ /dev/null @@ -1,6 +0,0 @@ -Feature: Numerals should be converted to written form. - -Scenario: Display number 4 in written form ("vier"). -Given the input "4" -When the converter is run -Then the output should be "vier" diff --git a/numerals/features/numerals_0-10-square.feature b/numerals/features/numerals_0-10-square.feature deleted file mode 100644 index ee4afa8..0000000 --- a/numerals/features/numerals_0-10-square.feature +++ /dev/null @@ -1,17 +0,0 @@ -Feature: numerals 1-10 should be squared. -Scenario Outline: Display square of numbers 1-10 as words -When the input is -Then the output should be - - Examples: - | number | word | - | 1 |"een" | - | 2 |"vier" | - | 3 |"negen" | - | 4 |"zestien" | - | 5 |"vijfentwintig" | - | 6 |"zesendertig" | - | 7 |"negenenveertig" | - | 8 |"vierenzestig" | - | 9 |"eenentachtig" | - |10 |"honderd" | diff --git a/numerals/features/numerals_0-20.feature b/numerals/features/numerals_0-20.feature deleted file mode 100644 index d3ad1b4..0000000 --- a/numerals/features/numerals_0-20.feature +++ /dev/null @@ -1,27 +0,0 @@ -Feature: numerals 1-20 should be translated. -Scenario Outline: Display uncomplicated numbers as words -When the input is -Then the output should be - - Examples: - | number | word | - | 1 |"een" | - | 2 |"twee" | - | 3 |"drie" | - | 4 |"vier" | - | 5 |"vijf" | - | 6 |"zes" | - | 7 |"zeven" | - | 8 |"acht" | - | 9 |"negen" | - |10 |"tien" | - |11 |"elf" | - |12 |"twaalf" | - |13 |"dertien" | - |14 |"veertien" | - |15 |"vijftien" | - |16 |"zestien" | - |17 |"zeventien"| - |18 |"achttien" | - |19 |"negentien" | - |20 | "twintig" | \ No newline at end of file diff --git a/numerals/features/numerals_base.feature b/numerals/features/numerals_base.feature deleted file mode 100644 index b697ae4..0000000 --- a/numerals/features/numerals_base.feature +++ /dev/null @@ -1,6 +0,0 @@ -Feature: Numerals should be converted to written form. - -Scenario: Display number 1 in written form ("een"). -Given the input "1" -When the converter is run -Then the output should be "een" diff --git a/numerals/features/numerals_dimitry.feature b/numerals/features/numerals_dimitry.feature deleted file mode 100644 index cd9c4da..0000000 --- a/numerals/features/numerals_dimitry.feature +++ /dev/null @@ -1,11 +0,0 @@ -Feature: Calculator must have Multiplication feature. - - Scenario: Show the multiplication of two numbers. - Given the input "2*2" - When the converter is run - Then the output should be "four" - - Scenario: Show multiplication is transitive. - Given the input "2*2*2" - When the converter is run - Then the output should be "eigth" diff --git a/numerals/features/numerals_divide.feature b/numerals/features/numerals_divide.feature deleted file mode 100644 index adfa336..0000000 --- a/numerals/features/numerals_divide.feature +++ /dev/null @@ -1,11 +0,0 @@ -Feature: Numerals should be dividable. - -Scenario: Show the division of two numbers. -Given the input "4/2" -When the converter is run -Then the output should be "2" - -Scenario: Show that the division of two numbers is transitive. -Given the input "100/5/4" -When the converter is run -Then the output should be "5" diff --git a/numerals/features/numerals_hex.feature b/numerals/features/numerals_hex.feature deleted file mode 100644 index 7da804b..0000000 --- a/numerals/features/numerals_hex.feature +++ /dev/null @@ -1,27 +0,0 @@ -Feature: numerals 1-20 should be translated. -Scenario Outline: Display uncomplicated numbers as hexadecimal characters -When the input is -Then the output should be - - Examples: - | number | hex | - |20 |"14" | - |21 |"15" | - |22 |"16" | - |23 |"17" | - |24 |"18" | - |25 |"19" | - |26 |"1A" | - |27 |"1B" | - |28 |"1C" | - |29 |"1D" | - |30 |"1E" | - |31 |"1F" | - |32 |"20" | - |33 |"21" | - |34 |"22" | - |35 |"23" | - |36 |"24"| - |37 |"25" | - |38 |"26" | - |39 | "27" | diff --git a/numerals/features/numerals_morse.feature b/numerals/features/numerals_morse.feature deleted file mode 100644 index 9b0c0f0..0000000 --- a/numerals/features/numerals_morse.feature +++ /dev/null @@ -1,11 +0,0 @@ -Feature: Numerals should be convertable to morse. - -Scenario: Display number 1 in morse (".----") -Given the input "1" -When the converter is run -Then the output should be ".----" - -Scenario: Display number 204 in morse ("..--- ----- ....-") -Given the input "204" -When the converter is run -Then the output should be "..--- ----- ....-") \ No newline at end of file diff --git a/numerals/features/numerals_plus.feature b/numerals/features/numerals_plus.feature deleted file mode 100644 index 0ec20e0..0000000 --- a/numerals/features/numerals_plus.feature +++ /dev/null @@ -1,16 +0,0 @@ -Feature: Numerals should be summable. - -Scenario: Show the sum of two numbers. -Given the input "1+1" -When the converter is run -Then the output should be "twee" - -Scenario: Show the power of a number -Given the input "2" -When the converter is run -Then the output should be "4" - -Scenario: Show that the sum of two numbers is transitive. -Given the input "1+1+1" -When the converter is run -Then the output should be "three" diff --git a/numerals/features/numerals_rikk.feature b/numerals/features/numerals_rikk.feature deleted file mode 100644 index 430506e..0000000 --- a/numerals/features/numerals_rikk.feature +++ /dev/null @@ -1,11 +0,0 @@ -Feature: log. - - Scenario: Show the result of log(100). - Given the input "log(100)" - When the converter is run - Then the output should be "2" - - Scenario: Show the result of log(1000). - Given the input "log(1000)" - When the converter is run - Then the output should be "3" diff --git a/numerals/features/numerals_roman.feature b/numerals/features/numerals_roman.feature deleted file mode 100644 index ccd269f..0000000 --- a/numerals/features/numerals_roman.feature +++ /dev/null @@ -1,14 +0,0 @@ -Feature: numerals 1,5,10,50,100,500,1000 should be converted to Roman numerals -Scenario Outline: Display numerals as Roman numerals -When the input is -Then the output should be - - Examples: - | number | letter | - | 1 | "I" | - | 5 | "V" | - | 10 | "X" | - | 50 | "L" | - | 100 | "C" | - | 500 | "D" | - | 1000 | "M" | diff --git a/numerals/features/numerals_russian_BjornC.feature b/numerals/features/numerals_russian_BjornC.feature deleted file mode 100644 index e01ab13..0000000 --- a/numerals/features/numerals_russian_BjornC.feature +++ /dev/null @@ -1,28 +0,0 @@ -Feature: Numerals 1-20 should be translated to Russian (phonetically) - -Scenario Outline: Display uncomplicated numbers as words. - When the input is - Then the output should be - - Examples: - | number | word | - | 1 |"adin"| - | 2 |"dva" | - | 3 |"tri" | - | 4 |"tsjetihri" | - | 5 |"pjat" | - | 6 |"sjest" | - | 7 |"sem" | - | 8 |"vosim" | - | 9 |"devjat" | - |10 |"desjat" | - |11 |"adinatsat" | - |12 |"dvanatsat" | - |13 |"trinatsat" | - |14 |"tsjetihrnatsat" | - |15 |"pjatnatsat" | - |16 |"sjestnatsat" | - |17 |"semnatsat" | - |18 |"vosimnatsat" | - |19 |"devjatnatsat" | - |20 | "dvatsat" | \ No newline at end of file diff --git a/numerals/features/numerals_spanish.feature b/numerals/features/numerals_spanish.feature deleted file mode 100644 index 25c2488..0000000 --- a/numerals/features/numerals_spanish.feature +++ /dev/null @@ -1,15 +0,0 @@ -Feature: Numerals 1-8 should be translated to Spanish. -Scenario Outline: Display uncomplicated numbers as words -When the input is -Then the output should be - - Examples: - | number | word | - | 1 |"uno" | - | 2 |"dos" | - | 3 |"tres" | - | 4 |"cuatro" | - | 5 |"cinco" | - | 6 |"seis" | - | 7 |"siete" | - | 8 |"ocho" | \ No newline at end of file diff --git a/numerals/features/sander.feature b/numerals/features/sander.feature deleted file mode 100644 index 5632141..0000000 --- a/numerals/features/sander.feature +++ /dev/null @@ -1,22 +0,0 @@ -Feature: numerals 1-15 should be translated to character. - Scenario Outline: Display uncomplicated numbers as characters - When the input is - Then the output should be - - Examples: - | number | character | - | 1 |"!" | - | 2 |"@" | - | 3 |"#" | - | 4 |"$" | - | 5 |"%" | - | 6 |"^" | - | 7 |"&" | - | 8 |"*" | - | 9 |"(" | - | 10 |"($(@" | - | 11 |"*$*#" | - | 12 |"^^^##@" | - | 13 |"(%*#)@)$&"| - | 14 |":)" | - | 15 |":(" | \ No newline at end of file diff --git a/numerals/features/step_definitions/numerals.rb b/numerals/features/step_definitions/numerals.rb index 1fbf92f..f3635de 100644 --- a/numerals/features/step_definitions/numerals.rb +++ b/numerals/features/step_definitions/numerals.rb @@ -1,11 +1,9 @@ - - Given(/^the input "(.*?)"$/) do |arg1| @input = arg1 end When(/^the converter is run$/) do - @output = `javac Main.java && java Main {@input}` + @output = `javac Main.java && java Main #{@input}` raise('Command failed!') unless $?.success? end