finished first code example for section3 chapter9, TryPath.java