A project containing Kata`s for practicing TDD using Kotlin. Each kata has its own package, and each exercise goals are described below.
- An empty string returns zero
- A single number returns the value
- Two numbers, comma delimited, returns the sum
- Two numbers, new line delimited, returns the sum
- Three numbers, delimited either way, returns the sum
- Negative numbers throw an exception
- Numbers greater then 1000 are ignored
- Password should be larger than 8 chars
- Password should have one uppercase letter at least
- Password should have one lowercase letter at least
- Password should have one number at least
- Each one of these should throw an exception with a different message of your choosing
- Password is OK if the previous conditions are satisfied
- Should return greeting for given name:
input"name"
outputHello, name.
- Should return generic greeting when no or empty name provided:
input"" or null
outputHello, my fiend
- Should return shouting greeting when shouting name provided:
input"NAME"
outputHELLO NAME!
- Should return greeting for both when two names provided:
input"name1", "name2"
outputHello, name1 and name2.
- Should return greeting for all when more than two names provided:
input"name1", "name2", "name3"
outputHello, name1, name2 and name3.
- Should return greeting when mixing shouting names with normal names:
input"name1", "NAME2", "name3"
outputHello, name1 and name3. AND HELLO NAME2!
- Should return greeting when coma separated names provided as input:
input"name1", "name2, name3"
outputHello, name1, name2, and name3.
- Should print numbers from 1 to 100
- For the multiples of 3 print
Fizz
instead of the number - For the multiples of 5 print
Buzz
instead of the number - For the multiples of both 3 and 5 print
FizzBuzz
instead of the number - A number is
Fizz
if it is dividable by 3 or if it contains 3 inside - A number is
Buzz
if it is dividable by 5 or if it contains 5 inside
Converter to resolve input from Roman numerals into decimal. The values of the roman numerals are shown in the following table.
Symbol | Value |
---|---|
I | 1 |
V | 5 |
X | 10 |
L | 50 |
C | 100 |
D | 500 |
M | 100 |
Numbers are formed by combining symbols together and adding the values. Generally, symbols are placed in order of value, starting with the largest values. When smaller values precede larger values, the smaller values are subtracted from the larger values, and the result is added to the total:
Roman Number | Computation | Value | Comment |
---|---|---|---|
IV | 5 - 1 | 4 | only subtraction |
VI | 5 + 1 | 6 | only addition |
MMVI | 1000 + 1000 + 5 + 1 | 2006 | only addition |
MCMXLIV | 1000 + (1000 - 100) + (50 - 10) + (5 - 1) | 1944 | addition and subtraction |
Simple bank application with the following features
- Deposit into Account
- Withdraw from an Account
- Print the Account statement to the console
Statement should have transactions in the following format:
DATE | AMOUNT | BALANCE
10/04/2014 | 500.00 | 1400.00
02/04/2014 | -100.00 | 900.00
01/04/2014 | 1000.00 | 1000.00
Constraints:
-
Start with a class with the following structure
public class Account { public void deposit(int amount) public void withdraw(int amount) public void printStatement() }
-
You are not allowed to add any other public methods in this class
-
Use Strings and Integers for dates and amounts (keep it simple)
-
Don't worry about the spacing in the statement printed in the console
Simple app for scanning bar codes to sell products
Scanning a barcode should display its price
- Barcode '12345' should display price '$7.25'
- Barcode '23456' should display price '$12.50'
- Barcode '99999' should display 'Error: barcode not found'
- Empty barcode should display 'Error: empty barcode'
- Introduce a concept of scanning multiple items
- Introduce a concept of `total` command that would display the sum of the scanned products
Legacy code that has to be improved. We have to make the code better while making sure we preserve the same behaviour. The idea is to cover the legacy code with tests to make sure we won't break its functionality, and once we are confident we can start refactoring, use as much as possible automated refactoring and minimise the manual refactoring for extra safety.