JMU CS446 - Software Analysis and Design
Help Policies Solutions Study-Aids Syllabus Tools
Programming Assignment 1


1 Purpose

The purpose of this assignment is to implement some of the classes that will be needed for the demonstration application, The Big Pixel, that will be used to test the capabilities of the application framework.

2 Learning Objectives

Though this assignment is a part of the activities/tasks that must be completed to implement the application framework, it is, in many ways, just a review of some object-oriented programming concepts that you should already be comfortable with.

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).

3 Preparatory Tasks

Before doing anything else you must:

4 Documents

The UML class diagram is available as an SVG file at:

The specifications are available as a PDF file at:

The main class (that can be used for integration testing) is available at:

5 Tasks

For this assignment you must:
  1. Implement all of the interfaces and classes in the class diagram and specifications document.
  2. Write JUnit tests for most of the classes in the class diagram and specifications document.

6 Testing

Your JUnit test suite must cover all statements and all branches (as measured by EclEmma) in the various classes other than the 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.

7 Submission

You must submit (using Autolab) a .zip file named pa1.zip that contains:
  1. Your implementation of the required interfaces/classes/enums in the appropriate package(s).
  2. JUnit tests for all of your classes/interfaces.

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.

8 Grading

Your submission will be graded as follows:

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.

9 Help

The following help topics may be useful to you.

9.1 Help with hashCode()

Java requires that you override the 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.
    Some IDE's (including some versions of Eclipse) have "wizards" that will write an appropriate hashCode() method for you.
    Objects.hash(java.lang.Object...) java.util.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).

9.2 Names of Parameters and Attributes

Specifications and UML class diagrams only contain parameter names so that the can be discussed. You should feel free to change parameter names if necessary. Team members rarely remember parameter names, so this rarely causes any confusion.

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.

9.3 Help with Warnings from the Static Analysis Tools

Given that you are probably still a little confused about parameterized classes (a.k.a. generics), the static analysis tools we are using may complain. In most cases, you should be able to fix the problem with a little bit of thought.

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.

9.4 Help with the Eclipse Project Explorer

The Eclipse Project Explorer normally filters-out (i.e., doesn't show) empty packages. To display them: clickg on the "Filters" icon (that looks like a funnel) in the Project Explorer, click on the "Pre-set filters" tab, and un-select "Empty packages" and "Empty parent packages".

9.5 Help with Coverage

In order to get 100% coverage, you sometimes have to be aware of some quirks of the language you are working in and the tool set you are using. For more information, see:

Copyright 2022