Added exercise 4: factory method