Junior — Senior
Creating a byte array according to FizzBuzz rules
livecode
Task condition
The method takes an integer number and returns a byte array formed according to the following principles:
- If the number is divisible by 3 — add the string
Fizzto the array. - If the number is divisible by 5 — add the string
Buzzto the array. - If the number is divisible by both 3 and 5 — add the string
FizzBuzzto the array. - If the number is not divisible by 3 or 5 — the method throws an
IllegalArgumentException. The solution should be accompanied by a set of unit tests.
public class FizzBuzzGenerator {
public byte[] generate(int number) {
throw new RuntimeException("Not implemented yet");
}
}