Fields
2 / 2  -are there 2 fields for the default minimum and maximum?
2 / 2  -are there non-static fields for the minimum and maximum?
 
Constructors
1 / 1  -does the no argument constructor initialize the range correctly?
1 / 1  -does the constructor throw the correct exception when required?
1 / 1  -does the constructor initialize the range correctly?
1 / 1  -does the copy constructor copy the other range correctly?

Methods
-getMinimum
1 / 1  -returns the correct value?

-getMaximum
1 / 1  -returns the correct value?

-setDefaultMinimum
1 / 1  -sets the default minimum when it should?

-setDefaultMaximum
1 / 1  -sets the default maximum when it should?

-contains
2 / 2  -returns the correct value?

-overlaps
0 / 2  -returns the correct value?
 
-centeredAt
1 / 2  -returns the correct range?

--------------------
TA Comments:

-overlaps:

        public boolean overlaps(Range other) {
                return this.contains(other.getMinimum()) || 
                                this.contains(other.getMaximum()) || 
                                other.contains(this.getMinimum()) || 
                                other.contains(this.getMaximum());
        }

-centeredAt:

        public static Range centeredAt(double value, double width) {
                double half = width / 2;
                

--------------------
Unit tester output:

YOUR SUMBISSION FAILED SOME UNIT TESTS
Here is the test output:

java -classpath .:/home/burton/work/teaching/2017F/2030/marking/secEtest2D/_jar/* org.junit.runner.JUnitCore test2.Test2Suite
JUnit version 4.12
..........E..E
Time: 0.019
There were 2 failures:

1) test10_overlaps(test2.RangeTest)
java.lang.AssertionError: overlaps should be true

2) test12_centeredAt(test2.RangeTest)
java.lang.IllegalArgumentException

FAILURES!!!
Tests run: 12,  Failures: 2

--------------------

Your submission:

package test2;

/**
 * A class that represents a range of values on the real number line. A range
 * has two properties: a minimum value and a maximum value. Range objects always
 * ensure that the following class invariant is true: <br>
 * <br>
 * 
 * <pre>
 * minimum value of this range is less than or equal to the maximum
 * value of this range
 * </pre>
 * 
 * <p>
 * The no-argument constructor creates a range using the default minimum and
 * maximum values; the initial minimum and maximum values are defined by the
 * <code>final</code> values <code>Range.INITIAL_DEFAULT_MIN</code> and
 * <code>Range.INITIAL_DEFAULT_MAX</code>. Clients are able to change the
 * default values (but not the initial default values) using the methods
 * <code>setDefaultMinimum</code> and <code>setDefaultMaximum</code>.
 * 
 */
public class Range {
        
        /**
         * The initial default minimum value of the Range class.
         */
        public static final double INITIAL_DEFAULT_MIN = 0;

        /**
         * The initial default maximum value of the Range class.
         */
        public static final double INITIAL_DEFAULT_MAX = 100;

        private static double DEFAULT_MIN = Range.INITIAL_DEFAULT_MIN;
        private static double DEFAULT_MAX = Range.INITIAL_DEFAULT_MAX;

        private double max;
        private double min;

        /**
         * Initialize this range so that its minimum and maximum values are equal to
         * the default minimum and maximum values of the Range class.
         */
        public Range() {
                this(Range.DEFAULT_MIN, Range.DEFAULT_MAX);
        }

        /**
         * Create a range with the specified minimum and maximum values.
         * 
         * @param min
         *            the minimum value of the range
         * @param max
         *            the maximum value of the range
         * @throws IllegalArgumentException
         *             if min is greater than max
         */
        public Range(double min, double max) {
                if (max < min) {
                        throw new IllegalArgumentException();
                }
                this.min = min;
                this.max = max;
        }

        /**
         * Initializes this range so that its minimum and maximum values are equal
         * to the minimum and maximum values of the specified other range.
         * 
         * @param other
         *            a range
         */
        public Range(Range other) {
                this(other.getMinimum(), other.getMaximum());
        }

        /**
         * Returns the minimum value of the range
         * 
         * @return the minimum value of the range
         */
        public double getMinimum() {
                return this.min;
        }

        /**
         * Returns the maximum value of the range
         * 
         * @return the maximum value of the range
         */
        public double getMaximum() {
                return this.max;
        }

        /**
         * Set the default minimum value of the Range class to the specified value.
         * If the specified value is greater than the default maximum value of the
         * Range class then the default minimum value is not changed by this method
         * (and no exception is thrown).
         * 
         * @param min
         *            the new default minimum value for the Range class
         */
        public static void setDefaultMinimum(double min) {
                if (min <= Range.DEFAULT_MAX) {
                        Range.DEFAULT_MIN = min;
                }
        }

        /**
         * Set the default maximum value of the Range class to the specified value.
         * If the specified value is less than the default minimum value of the
         * Range class then the default maximum value is not changed by this method
         * (and no exception is thrown).
         * 
         * @param max
         *            the new default maximum value for the Range class
         */
        public static void setDefaultMaximum(double max) {
                if (max >= Range.DEFAULT_MIN) {
                        Range.DEFAULT_MAX = max;
                }
        }

        /**
         * Checks if <code>value</code> is inside this range. A value is considered
         * inside this range if the value is greater than or equal to the minimum
         * value of this range and the value is less than or equal to the maximum
         * value of this range.
         * 
         * @param value
         *            the value to check
         * @return true if value is inside this range, and false otherwise
         */
        public boolean contains(double value) {
                return (value >= this.min) && (value <= this.max);
        }

        /**
         * Checks if this range overlaps with another range. Two ranges overlap if
         * at least one <code>double</code> value is contained by both ranges. For
         * example, the two ranges
         * 
         * <p>
         * <code>[0.1, 0.8]</code> and <code>[0.6, 2.5]</code> overlap because all
         * values between <code>0.6</code> and <code>0.8</code> are contained by
         * both ranges.
         * 
         * <p>
         * The two ranges
         * 
         * <p>
         * <code>[-0.25, 0.33]</code> and <code>[0.33, 1.0]</code> overlap because
         * both ranges contain the value <code>0.33</code>
         * 
         * 
         * @param other
         *            the other range to check
         * @return true if this range overlaps with other, and false otherwise.
         */
        public boolean overlaps(Range other) {
                return this.contains(other.getMinimum()) || this.contains(other.getMaximum());
        }

        /**
         * Return a new range that is centered at <code>value</code> and whose total
         * width is <code>width</code>. For example:
         * 
         * <p>
         * <code>Range.centeredAt(10.0, 5.0)</code>
         * 
         * <p>
         * would return the range <code>[7.5, 12.5]</code>.
         * 
         * 
         * @param value
         *            the center of the desired range
         * @param width
         *            the total width of the desired range
         * @return a new Range of the specified width centered at the specified
         *         value @pre. width is greater than or equal to zero
         */
        public static Range centeredAt(double value, double width) {
                return new Range(width - (value / 2), width + (value / 2));
        }
}

--------------------

Written answers marking scheme

A 
2 / 2  is a suitable definition given?

B
1 / 1  no this is not a good implementation?
2 / 2  is there a suitable explanation?

C 
1 / 1  incorrect signature?
1 / 1  check for null before using obj.getClass()?
1 / 1  && should be || ?
2 / 2  x.equals(null) does not return false

D 
2 / 2  constructor chaining?

--------------------
TA Comments

--------------------

Your submission:

A.      It means that the field can not be changed if it is a primitive, and it
        can not point to another object if it is an object. 

B.      No, because in the following example:

                Range r = new Range(0.0, 1.0);
                Range r1 = new Range(0.5, 1.5);
                Range r2 = new Range( 1.25, 2.25);
                System.out.println(r.compareTo(r1));
                System.out.println(r1.compareTo(r2));
                System.out.println(r.compareTo(r2));
        
                the three print statements would result in [0, 0, -1], which violates the rule that
                x.compareTo(y)==0 implies that sgn(x.compareTo(z)) == sgn(y.compareTo(z)), for all z.
                (As stated in the documentation). 
                Also, there are no exceptions thrown which are defined in the documentation.

C.
        a)
                -       Because the signature of the method shows that the method assumes the object
                        will be a range object, it can not override a method, because that method does
                        not exist to be overridden.
                -       If the passed in value is null, then the obj.getClass() will throw a
                        NullPointerException because the method only checks if the object is null
                        after the method checks if the classes are the same.    
                -       The method only returns false if both of the fields are different, not just
                        one of them.
        b)      Doesn't return false if it is null because of the exception.

D.      Copy Constructor

--------------------