Implemented workshop4 code in class.