ICS 111 Homework Assignment H08: Addition Quiz with classes.

Purpose

We are going to continue our problem-solving education by writing a program that uses classes and instances to administer a hexadecimal addition quiz, much like H06 Addition Quiz. Hopefully using instances will make this assignment much easier.

We will also get more practice using Eclipse to make our programming life easier.

Tasks

1. Create a package named edu.ics111.h08 in your ICS111-workspace project

This is where we will put all our classes for homework 08.

In homework H06 asked you to write a program that administers a 10-question hexadecimal addition quiz. Rewrite that program so that it uses the following class to represent addition questions:

package edu.ics111.h08;

/**
 * Represents a HexAdditionQuestion.
 *
 * @author Cam Moore
 *
 */
public class HexAdditionQuestion {
  private int a1;
  private int b1;

  /**
   * Creates a new HexAdditionQuestion.
   *
   */
  public HexAdditionQuestion() { // constructor
    a1 = (int)(Math.random() * 50 + 1);
    b1 = (int)(Math.random() * 50); 
  }

  /**
   * Returns the question.
   * @return the question.
   */
  public String getQuestion() {
    return "What is " + asHex(a1) + " + " + asHex(b1) + " ?";
  }

  /**
   * Returns the correct answer.
   * @return the correct answer.
   */
  public int getCorrectAnswer() {
    return a1 + b1;
  }

  /**
   * Returns the correct answer as a Hex String.
   * @return the correct answer as a Hex String.
   */
  public String correctAnswerAsHex() {
    return Integer.toHexString(a1 + b1);
  }

  private String asHex(int val) {
    return Integer.toHexString(val);
  }
}

Grading Rubric

CriterionExcellent (100%)Satisfactory (75%)Borderline (50%)Unsatisfactory (25%)Poor (0)
Adherence to standards - 2 points
Does it conform to standards in every detail?
No errors. Minor details of the assignment are violated, or poor choices are made where the assignment is unclear. Significant details of the assignment or the underlying program intent are violated, but the program still fulfills essential functions. Significant details of the assignment or the underlying program intent are violated, but the program still fulfills some essential functions. Misses the point of the assignment.
Breakdown (modular design) - 2 points
Does it demonstrate good modular design?
No errors. 1-3 minor errors. > 3 minor errors OR 1 major error. 2 major errors > 2 major error.
Correctness of code - 4 points
Does it work? Does it pass JUnit?
Passes all tests. Works for typical input, may fail for minor special cases. Fails for typical input, for a minor reason. Fails for typical input, for a major reason. No.
Documentation, and style - 2 points
Is it clear and maintainable? Does it pass CheckStyle?
No errors. 1-3 minor errors. > 3 minor errors OR 1 major error. 2 major errors > 2 major error.

Turning in the Assignment

The assignment is due on Friday, October 29th at 11:55pm. You may turn it in early.