update from cop4331 assignment 2. Used OOP principles