exercise 2.49 segments->painter