The only material in this assignment that might be new to you is related to 2D graphics, assertions, and parameterized classes (also known as generics).
The specifications are available as a PDF file at:
The main class (that can be used for integration testing) is available at:
GridComponent
class.
Your tests must be in a package
named edu.jmu.cs.academics.testing
and each test class
must include the word "Test" in its name.
.zip
file named pa1.zip
that contains:
Do not submit the main class.
You must submit (using Canvas) two PDF files that contain
screenshots of The Big Pixel while it is running.
One must contain a GridComponent
constructed
using the default constructor and with visible headers, and the other
must contain a GridComponent
constructed using the
explicit value constructor with parameters of 5, 5, and 30 and
without visible headers.
Note that your code will not be assessed at all if it does not compile or does not conform to the specifications. Hence, before you do anything else, you should stub-out all of the classes so that you can get submit your code for partial credit even if you do not complete the assignment.
Note, also, that your code will not be assessed against subsequent criteria if it does not satisfy a criterion that is described as "Success Required". In this case, your code must conform to the style guide and must pass your tests for the coverage of your tests and the correctness of your code to be assessed.
Note, finally, that, you can earn a grade of 40 on the assignment even if none of your code is correct, as long as it conforms to the style guide and passes your tests. You can earn a grade of 60 even if none of your code is correct as long as it is also completely covered by your tests.
hashCode()
method
whenever you override the equals()
method because
the equals()
method is used to determine logical
equivalence between object instances and the hashCode()
method must return the same value for all equivalent
objects.
hashCode()
method for you.Objects.hash(java.lang.Object...)
can be used to create a hash code from an objects identifying attributes.
You should understand hash codes and the various algorithms that have been proposed for solving this "problem". Don't use a method that you don't understand.
Remember that most hashing algorithms are not perfect (i.e., there may be collisions). So, a hashing algorithm may return the same hash code for two objects that are not "equal". However, as mentioned above, the converse must not be true (i.e., two objects that are "equal" must have the same hash code).
Attribute names tend to be remembered by team members (often because they have associated getters and setters). Hence, though there is no technical reason that they can't be changed, doing so should be avoided.
However, in some cases, it may be impossible. For example, in the
CellID
class, the equals(Object)
method
should call the equals(CellID<C,R>)
method
(to avoid code duplication) and this will require a type cast.
You can check to ensure that the cast will be safe using
the instanceof
operator, but the static analysis tool
will still tell you it is unsafe. You can inform the tools that
it is incorrect using the @SuppressWarnings("unchecked")
annotation.
You may also find it necessary to use the
a @SuppressWarnings("rawtypes")
annotation.
Do not overuse these annotations. Make sure it really is impossible to eliminate the warning and that what you are doing is really safe before you use them.
Copyright 2022