Advertisement
Guest User

Untitled

a guest
Apr 26th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.io.File;
  2. import java.io.FileNotFoundException;
  3. import java.util.Scanner;
  4.  
  5. public class Prog7a<E> {
  6. public static void main(String[] args) throws FileNotFoundException {
  7. checkUsage(args);
  8.  
  9. // try {
  10. // File fInput = new File(args[0]);
  11. // File fInput = new File("FIXME");
  12. // fReader = new Scanner(fInput);
  13. // }
  14. // catch (FileNotFoundException fnfe) {
  15. // System.out.println("File not found");
  16. // System.exit(0);
  17. // }
  18.  
  19. if (args[0].equals("I") || args[0].equals("i") || args[0].equals("S") || args[0].equals("s")
  20. || args[0].equals("D") || args[0].equals("d")) {
  21. // If input is I then
  22. if (args[0].equals("I") || args[0].equals("i")) {
  23. ArrayList<Integer> intList = new ArrayList<Integer>();
  24. for (int i = 2; i < args.length; i++) {
  25. intList.add(Integer.parseInt(args[i]));
  26. System.out.println(args[i]);
  27. }
  28. }
  29. // If input is S then
  30. else if (args[0].equals("S") || args[0].equals("s")) {
  31. ArrayList<String> stringList = new ArrayList<String>();
  32. for (int i = 2; i < args.length; i++) {
  33. stringList.add(args[i]);
  34. System.out.println(args[i]);
  35. }
  36. }
  37. // If input is D then
  38. else {
  39. ArrayList<Double> doubleList = new ArrayList<Double>();
  40. for (int i = 2; i < args.length; i++) {
  41. doubleList.add(Double.parseDouble(args[i]));
  42. System.out.println(args[i]);
  43. }
  44. }
  45. } else {
  46. System.out.println("Incorrectly formatted command.");
  47. }
  48. }
  49.  
  50. public static void checkUsage(String[] args) {
  51. if (args.length < 3){
  52. System.out.println("Usage: java Prog7a <Data Type \"I, S, or D\"> "
  53. + "<Number of variables> <List of variables separated by spaces>");
  54. System.exit(0);
  55. }
  56. }
  57.  
  58. } // class
  59.  
  60. // dont forget to import
  61. class SuperArrayList<E> extends ArrayList<E> {
  62. public ArrayList<E> removeDuplicates(ArrayList<E> list) {
  63. ArrayList<E> newList = null;
  64. return this;
  65. }
  66.  
  67. public void shuffle(ArrayList<E> list) {
  68.  
  69. }
  70.  
  71. // this will cause a problem - will explain in chat
  72. public <E extends Comparable<E>> E max(ArrayList<E> list) {
  73. return null;
  74. }
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement