Homework 3 - Exceptions

Introduction

In this “mini-homework” assignment you will practice

Problem Description

You need to add invalid square checking to your square class and ensure that it works properly before continuing to rewrite your PGN reader.

Solution Description

Write or modify the following classes:

For each class include Javadoc comments as described in the CS 1331 style guide.

We will test your classes with code similar to the following. You should too. (Assume fail(String) and assertEquals(T, T) are implemented appropriately in these examples.)

try {
    new Square("a1");
} catch (InvalidSquareException e) {
    fail("InvalidSquareException for valid square: " + e.getMessage());
}
try {
    String invalidSquare = "a9";
    new Square(invalidSquare);
    fail("No InvalidSquareException for invalid square: " + invalidSquare);
} catch (InvalidSquareException e) {
    // Success
}
Square s = new Square("f7");
assertEquals('f', s.getFile());
assertEquals('7', s.getRank());
Square s2 = new Square('e', '4');
assertEquals("e4", s2.toString());

Grading

Checkstyle deduction will be capped at 30 points for this homework.

Turn-in Procedure

Submit each of your Java source files on T-Square as separate attachments. When you’re ready, double-check that you have submitted and not just saved a draft.

Verify the Success of Your Submission to T-Square

Practice safe submission! Verify that your HW files were truly submitted correctly, the upload was successful, and that your program runs with no syntax or runtime errors. It is solely your responsibility to turn in your homework and practice this safe submission safeguard.