//IntSumWithWildcard.java
//Exactly the same as IntSumWithWildcard.java except that T in line 30
//has been replaced by the "wildcard character" '?'.

//Question being asked here:
//Is the "integer sum" of the values in the T array the same, no
//matter what kind of (numeric, of course) values are in the array?
public class IntSumWithWildcard<T extends Number>
{
    private T[] values;

    public IntSumWithWildcard(T[] a)
    {
        values = a;
    }

    //Return an integer sum in all cases.
    public int intSum()
    {
        double sum = 0.0;
        for (int i = 0; i < values.length; i++)
        {
            sum += values[i].doubleValue();
        }
        return (int) sum;
    }

    //Return an integer sum in all cases.
    public boolean hasSameIntSum(IntSumWithWildcard<?> obj)
    {
        if (this.intSum() == obj.intSum()) //"this" is redundant here
        {
            return true;
        }
        return false;
    }
}
