Work on these for about 80 minutes (ie the time for the lab). I do not expect you to do them all in 80 minutes. I doubt anyone will get to the all subsets problem.
In this lab you will write, a several small programs in Java. The intent here is simply to get you some practice with Java before writing some of these same small programs in a new language, Go. Your programs need not be hugely protected against failure (ie minimal, or no, exception handing is fine) but they should actually run and produce valid output on any valid input.java KM 10 kthen the output would be "6.14 miles". Conversely, if your command line was
java KM 5 mthen the output should be "8.05 k"
Add to your class a new, public method named slicer. Slicer should behave according to the following documentation
/** * This function takes two parameters, the start and the count. * It returns a new instance of the class that contains the items * starting at the start index and with the given count. For example * if the current instance contains [0,1,2,3,4,5,6,7,8,9] and this * method was called with the the parameters 1,3 it would return * a new instance of the class with [1,2,3]. With parameters * 4,5 it would return [4,5,6,7,8] * If the first number is less than 0, count backwards from the end. * For example -3,2 would give [7,8]. * @param start the index (the first item is at index 0) * of the first item in the current list to * be copied into the new list. If start index is less than 0, * start at length-start index. * @param count the number of items to be copied. If count is too large * return as many as are available. If count is less than 0, return all items * to the end of the current list. * @return a new class containing a subset of the objects in the * source class */ public ExtArrayListslicer(int start, int count) {
import java.util.Arrays; public class ChPr { public int[] chPrimes = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 47, 53, 59, 67, 71, 83, 89, 101, 107, 109 }; public void printer() { System.out.println(Arrays.toString(chPrimes)); } public static void main(String[] args) { (new ChPr()).printer(); } }
public ArrayList<ArrayList<T>> allSubsets(ArrayList<T>)
Some thoughts:
Send a single email to gtowell@brynmawr.edu with the all of the code you wrote. Your code should be reasonably close to correct. It need not be commented and as above, it need be only minimally exception protected. If you worked in a pair, one email will be enough, just be clear on who worked.