Code written for advanced Java course