Lab 09

CSCI 1913 – Introduction to Algorithms, Data Structures, and Program Development

Set up environment

  • Start an IntelliJ project
  • Download the files for this project and move the .java to the src folder
  • The image files must be placed correctly. These should go in folders (named expectedImages and sourceImages) in the root folder of the project (NOT in src) – if these are misplaced you will have trouble getting tests to run
  • You should also create a folder named outputImages

Folder Structure

Your intelij project directory should look something like the following:

.
lab09
|-- expectedImages
|   |-- buininks_inside_G.png
|   `-- ...
|-- out
|-- outputImages
|-- sourceImages
|   |-- buininks.png
|   `-- ...
`-- src
    |-- AddBorder.java
    |-- Brighten.java
    |-- ColorPallet.java
    `-- ...

Javadoc

Key Rules:

  • Starts with /** and ends with */
  • First sentence is a short summary — it appears in the generated HTML overview
  • @param tag should be listed for every parameter

Javadoc

   /**                                                                               
   * Calculates the average of an array of test scores.
   * Returns 0 if the array is null or empty.    
   *              
   * @param scores  an array of test scores, each in the range [0, 100]
   * @param count   the number of scores in the array
   * @return        the average of all scores, or 0 if the array is null or empty
   * @throws        IllegalArgumentException if count is negative
   *
   * @author        Adriana Picoral
   * @version       1.0
   */
  public double calculateAverage(double[] scores, int count) {
      if (scores == null || scores.length == 0) return 0;
      if (count < 0) throw new IllegalArgumentException("Count cannot be negative");

      double sum = 0;
      for (double score : scores) {
          sum += score;
      }
      return sum / count;
  }