finished part 4 of the assignemnt, refactored into three classes