My school's assignment in Java OOP