Lab 05 - Factory Method, Option, Lazy Evaluation
Factory method
abstract class Task {
private int amount;
public static Task of(int type, int amount) {
switch (type) {
case 0:
return new DepositTask(amount);
case 1:
return new WithdrawalTask(amount);
case 2:
return new CurrencyExchangeTask(amount);
case 3:
return new TransferTask(amount);
case 4:
return new LoanTask(amount);
default:
throw new IllegalArgumentException("No such task");
}
}
}Singleton
Caching
Error-Handling
Exercise 5 Review
Maybe
map and flatMap
Lab Sheet
1
2
3
Tips
Last updated