In this exercise we will practice the jGRASP debugger using the Case Study example from the end of Chapter 6. To download this example, follow these steps:
ZipLookup.java
and zipcode.txt
.
Right-click the file names and choose the option to save the link in whatever folder you have been using for lab work.
Make sure to save them in the same folder.
ZipLookup.java
in jGRASP.
You might try using your own ZIP code and a relatively small radius like 0.5 miles.
The program takes a while to run because it has to search a large data file.
continued on the next slide...
ZipLookup
program.
find
.
Then it shows all matches in the method named showMatches
.
We want to debug showMatches
.
continued on the next slide...
What zip code are you interested in? 20500 And what proximity (in miles)? 0.3 20500: Washington, DC zip codes within 0.3 miles: 20045 Washington, DC, 0.26 miles 20500 Washington, DC, 0.00 miles 20501 Washington, DC, 0.27 miles 20502 Washington, DC, 0.27 miles
while
loop in the showMatches
method executes.
Set a break point on the while
loop itself.
Then debug to find lat1
and long1
(latitude and longitude of the White House ZIP code).
lat1 |
38.894781 |
|
long1 |
-77.036122 |
continued on the next slide...
Clear your previous break point and set a new break point inside on the printf
inside the if
.
Then hit the resume button that looks like a play button and fill in the table below with the values for zip
, lat2
, and long2
.
zip |
lat2 |
long2 |
---|---|---|
20045 | 38.896599 | -77.0319 |
20500 | 38.894781 | -77.036122 |
20501 | 38.89872 | -77.036198 |
20502 | 38.89872 | -77.036198 |