solved exercise 2.1 from oop5