package eecs2030.test2;
import java.util.ArrayList;
import java.util.List;
public class Test2H {
/**
* The size of the list required by the method Test2G.avg2
*/
public static final int AVG2_LIST_SIZE = 2;
private Test2H() {
// empty by design
}
/**
* Returns true if tf
is false, and false if
* tf
is true.
*
* @param tf a boolean value
* @return the opposite of tf
*/
public static boolean not(boolean tf) {
return !tf;
}
/**
* Given a list containing exactly 2 integers, returns the average of the
* two integers. The list t
is not modified by this method.
* For example:
*
*
* t Test2F.avg2(t) * --------------------------- * [-5, 9] 2 * [3, 3] 3 * [12, 7] 9.5 ** * @pre t is not null * * @param t * a list containing exactly 2 integers * @return * the average of the two values in t * @throws IllegalArgumentException * if the list does not contain exactly 2 integers */ public static double avg2(List
t
.
* The list t
is not modified by this method.
* The sum of an empty list is zero. If the sum of the values
* is greater than Integer.MAX_VALUE
then
* Integer.MAX_VALUE
is returned.
* If the sum of the values
* is less than Integer.MIN_VALUE
then
* Integer.MIN_VALUE
is returned.
*
* @param t a list of values
* @return the sum of the values in t
* @pre t is not null
*/
public static int sum(Listn
.
* For example:
*
* * n Test2H.fromInt(n) * ----------------------------------- * 0 [0] * -25 [-2, 5] * 9876543 [9, 8, 7, 6, 5, 4, 3] ** * @param n a number * @return a list consisting of the individual digits of the number
n
*/
public static List