CSE142—Computer Programming I

Programming Assignment #6

Debugging Hints

Java Version

You can get a significant pixel difference if you are using an older version of Java.  In particular, you might see pixel differences for the strings that are drawn on the DrawingPanel if you are not using Java 11.  You can find out which version is running by going into the interactions pane in jGRASP and typing in the following:

System.getProperty("java.version")

You should see a response like the following:

11.0.1

To change which version of Java jGRASP is using, go to Settings, jGRASP Startup Settings, and look for “Java executable for running jGRASP.”  Pick something that begins with “11.”  If you don’t see something that begins with “11”, then you need to install a newer JDK first by following the instructions on the “Working at Home” tab on the class web page.

Drawing Counts

It is possible to get a large pixel difference if you draw the same line or string multiple times.  The DrawingPanel class has an option to help you explore this.  Set up your Graphics object this way:

Graphics g = p.getDebuggingGraphics();

When you do so, you can include the following line of code after you finish the drawing commands:

System.out.println(p.getCounts());

This is the output produced by the sample solution for names.txt:

{drawLine=29, drawString=28}

This is the output produced by the sample solution for names2.txt:

{drawLine=21, drawString=20}

You do not have to match these counts if you are within 500 pixels of difference.  Be sure to remove any debugging printlns before you turn in your program because otherwise your program will not match the sample logs of execution.

Use the IPL Computers

You will also see significant pixel differences depending upon what operating system you are using and which version of that operating system.  In particular, you will see different fonts being used by different operating systems.  The output comparison includes one standard Windows version and two different Mac versions, but this will not cover all of the possibilities.  We make sure that the computers at the IPL are properly configured to match our sample output, so you can always stop by the IPL and run your program on one of those computers to check whether a pixel difference is happening because of configuration issues.