completed hw09 by breaking the problem into sub problems and solving them in separate classes