Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.File;
- import java.io.FileNotFoundException;
- import java.util.Scanner;
- public class Prog7a<E> {
- public static void main(String[] args) throws FileNotFoundException {
- checkUsage(args);
- // try {
- // File fInput = new File(args[0]);
- // File fInput = new File("FIXME");
- // fReader = new Scanner(fInput);
- // }
- // catch (FileNotFoundException fnfe) {
- // System.out.println("File not found");
- // System.exit(0);
- // }
- if (args[0].equals("I") || args[0].equals("i") || args[0].equals("S") || args[0].equals("s")
- || args[0].equals("D") || args[0].equals("d")) {
- // If input is I then
- if (args[0].equals("I") || args[0].equals("i")) {
- ArrayList<Integer> intList = new ArrayList<Integer>();
- for (int i = 2; i < args.length; i++) {
- intList.add(Integer.parseInt(args[i]));
- System.out.println(args[i]);
- }
- }
- // If input is S then
- else if (args[0].equals("S") || args[0].equals("s")) {
- ArrayList<String> stringList = new ArrayList<String>();
- for (int i = 2; i < args.length; i++) {
- stringList.add(args[i]);
- System.out.println(args[i]);
- }
- }
- // If input is D then
- else {
- ArrayList<Double> doubleList = new ArrayList<Double>();
- for (int i = 2; i < args.length; i++) {
- doubleList.add(Double.parseDouble(args[i]));
- System.out.println(args[i]);
- }
- }
- } else {
- System.out.println("Incorrectly formatted command.");
- }
- }
- public static void checkUsage(String[] args) {
- if (args.length < 3){
- System.out.println("Usage: java Prog7a <Data Type \"I, S, or D\"> "
- + "<Number of variables> <List of variables separated by spaces>");
- System.exit(0);
- }
- }
- } // class
- // dont forget to import
- class SuperArrayList<E> extends ArrayList<E> {
- public ArrayList<E> removeDuplicates(ArrayList<E> list) {
- ArrayList<E> newList = null;
- return this;
- }
- public void shuffle(ArrayList<E> list) {
- }
- // this will cause a problem - will explain in chat
- public <E extends Comparable<E>> E max(ArrayList<E> list) {
- return null;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement