Complete the methods getSmaller, getLarger, and getOrderedPair in the following class of pairs of integers: /** Represents pairs of integers. */ public class Pair { private int one; private int two;...



Complete the methods getSmaller, getLarger, and getOrderedPair in the following class of pairs of integers:


/** Represents pairs of integers. */


public class Pair


{


private int one;


private int two;


public Pair(int oneNumber, int anotherNumber)


{


one = oneNumber;


two = anotherNumber;


} // end constructor


/** Returns the smaller integer in this pair. */


public int getSmaller()


{


. . .


} // end getSmaller


/** Returns the larger integer in this pair. */


public int getLarger()


{


. . .


} // end getLarger


/** Returns a new pair whose integers are the same as in


this pair, but whose first integer is the smaller one. */


public Pair getOrderedPair()


{


. . .


} // end getOrderedPair




public String toString()


{


return one + ", " + two;


} // end toString


} // end Pair



May 18, 2022
SOLUTION.PDF

Get Answer To This Question

Submit New Assignment

Copy and Paste Your Assignment Here