blob: 8ae46f114e07df8fa9223c53649a65bfe9e75a03 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
public class Main {
public static void main(String[] args) {
if (args.length < 1) {
System.out.println("""
Please provide:
1. fibonacci number to compute, and
2. (optional) the calculation method (naive or cached).""");
}
else {
FibonacciNumberFactory factory;
if (args.length >= 2 && args[1].equals("naive")) {
factory = new NaiveFibonacciNumberFactory();
}
else {
factory = new CachedFibonacciNumberFactory();
}
FibonacciCalculator calculator = new FibonacciCalculatorImpl(factory);
System.out.println(factory.getFibonacciNumber(Integer.parseInt(args[0])).calculate(calculator));
}
}
}
|