Pair Class
/**
*A pair of integers can be added, subtracted, multiplied, divided, and averaged out;
*the absolute value of the difference can be found and the max and min numbers can be found.
*/
public class Pair
{
private int one;
private int two;
/**
*Creates a pair initialized to 0.
*/
public Pair()
{
one=0;
two=0;
}
/**
*Creates a pair intitialized to specified numbers.
*@param newOne Specifies the first integer.
*@param newTwo Specifies the second integer.
*/
public Pair(int newOne, int newTwo)
{
one=newOne;
two=newTwo;
}
/**
*Returns the sum of the pair.
*@return Returns the sum.
*/
public int getSum()
{
return one+two;
}
/**
*Returns the difference of the pair.
*@return Returns the difference.
*/
public int getDif()
{
return one-two;
}
/**
*Returns the product of the pair.
*@return Returns the product.
*/
public int getProduct()
{
return one*two;
}
/**
*Returns the average of the pair.
*@return Returns the average.
*/
public double getAverage()
{
return (one+two)/2;
}
/**
*Returns the absolute value of the difference or the distance of the pair.
*@return Returns the distance.
*/
public int getDistance()
{
if (getDif()>0)
return getDif;
else
return getDif*(-1);
}
/**
*Returns the greater of the pair.
*@return Returns the greater.
*/
public int getMax()
{
if(one>two)
return one;
else
return two;
}
/**
*Returns the lesser of the pair.
*@return Returns the lesser.
*/
public int getMin()
{
if(one
Home