My solution for university java course