- You are not allowed to write any production code unless it is to make a failing unit test pass.
- You are not allowed to write any more of a unit test than is sufficient to fail; and compilation failures are failures.
- You are not allowed to write any more production code than is sufficient to pass the one failing unit test.
Which means the workflow is:
- Write a failing test. Stop writing the test as soon as it fails.
- Write the minimal production code required for the test to pass. Stop writing any code once the test passes.
- Refactor the test code and the production code without altering the functionality. All tests should pass.
- Must be able to tell its size
- Must be able to tell if isEmpty
- Must be able to push an integer
- Must be able to pop last integer pushed
No cheating! Use only a native array of integers.
- Empty at creation
- Size zero at creation
- Size one after single push
- Size returns to zero after single pop
- Size increments with multiple pushes
- Size decrements with multiple pops
- Same element popped as pushed
- Elements popped in LIFO order
A Set is an UNORDERED collection that contains NO DUPLICATE values. Methods:
add(Int)
contains(Int)
isEmpty()
remove(Int)
size()
No cheating! Use only a native array of integers.
- Empty at creation
- Size zero at creation
- Size one after single add
- Size increments with multiple adds
- Contains for non existing element
- Contains for existing element
- Delete non-existing element, size remains unchanged
- Delete existing element, size decrements
- Delete element, no longer contains
- Insert duplicates, size does not increment
- Returns an array of a given size
- A given size returns an array of strings, counting from 1 to the given size
1 => ["1"]
,5 => ["1","2","3","4","5"]
,10 => ["1","2","3","4","5","6","7","8","9","10"]
- for multiples of three, return "Fizz” instead of the number
3 => ["1","2","Fizz"]
- for multiples of five, return "Buzz"
5 => ["1","2","Fizz","4","Buzz"]
- For numbers which are multiples of both three and five, return "FizzBuzz".
- I don't know... what tests should you write? ;)
- for multiples of seven, print "Bang!"
- for multiples of three and seven, print "FizzBang!"
- for multiples of five and seven, print "BuzzBang!"
- for multiples of three, five, and seven, print "FizzBuzzBang!"
- Write a method "add" that, given a delimited string, returns the sum of the numbers in the string.
- An empty string returns zero
'' => 0
- A single number returns the value
'1' => 1
,'2' => 2
- Two numbers, comma delimited, returns the sum
'1,2' => 3
,'10,20' => 30
- Two numbers, newline delimited, returns the sum
'1\n2' => 3
- Three numbers, delimited either way, returns the sum
'1\n2,3\n4' => 10
- Numbers greater than 1000 are ignored
- A single char delimiter can be defined on the first line starting with
//
(e.g//#\n1#2
for a ‘#’ as the delimiter) - A multi char delimiter can be defined on the first line starting with
//
(e.g.//###\n1###2
for ‘###’ as the delimiter)