implemented adjacent() and corresponding unit test.