/* the key to our approach here:

> import java.util.ArrayList; // auto-import
ArrayList<Integer> a = new ArrayList<Integer>();
> a.add(3)
true
> a.contains(5)
false
> a.contains(3)
true


 */ 

import java.util.ArrayList;

public class Seven {
  public static void main(String[] args) {
    ArrayList<Integer> a = Seven.noDuplicates(Integer.parseInt(args[0]), 
                                              Integer.parseInt(args[1]), 
                                              Integer.parseInt(args[2]));  
    System.out.println( a ); 
  }
  public static ArrayList<Integer> noDuplicates(int size, int low, int high) {
    ArrayList<Integer> result = new ArrayList<Integer>(); 
    System.out.println("Current array list: " + result ); 
    for (int i = 0; i < size;       ) { 
      int number = (int)(Math.random() * (high - low) + low); 
      if (result.contains(number)) {
        System.out.print ( "Randomly we look at: " + number + " but we can't accept it. " ); 
        System.out.println( "The array list remains: " + result ); 
      } else { 
        System.out.print ( "Randomly we select " + number + " and we keep it. ");  
        result.add(number); 
        System.out.println( "The array list becomes: " + result );
        i = i + 1; 
      }
    }
    return result; 
  }
}

/* here's how this runs:

Welcome to DrJava.  Working directory is C:\Users\cogli\Desktop
> java Seven 3 5 15
Current array list: []
Randomly we select 11 and we keep it. The array list becomes: [11]
Randomly we select 6 and we keep it. The array list becomes: [11, 6]
Randomly we select 7 and we keep it. The array list becomes: [11, 6, 7]
[11, 6, 7]
> java Seven 3 5 15
Current array list: []
Randomly we select 14 and we keep it. The array list becomes: [14]
Randomly we select 10 and we keep it. The array list becomes: [14, 10]
Randomly we select 8 and we keep it. The array list becomes: [14, 10, 8]
[14, 10, 8]
> java Seven 10 5 15
Current array list: []
Randomly we select 6 and we keep it. The array list becomes: [6]
Randomly we select 12 and we keep it. The array list becomes: [6, 12]
Randomly we select 11 and we keep it. The array list becomes: [6, 12, 11]
Randomly we select 8 and we keep it. The array list becomes: [6, 12, 11, 8]
Randomly we select 14 and we keep it. The array list becomes: [6, 12, 11, 8, 14]
Randomly we look at: 11 but we can't accept it. The array list remains: [6, 12, 11, 8, 14]
Randomly we select 9 and we keep it. The array list becomes: [6, 12, 11, 8, 14, 9]
Randomly we look at: 8 but we can't accept it. The array list remains: [6, 12, 11, 8, 14, 9]
Randomly we select 13 and we keep it. The array list becomes: [6, 12, 11, 8, 14, 9, 13]
Randomly we select 5 and we keep it. The array list becomes: [6, 12, 11, 8, 14, 9, 13, 5]
Randomly we select 7 and we keep it. The array list becomes: [6, 12, 11, 8, 14, 9, 13, 5, 7]
Randomly we select 10 and we keep it. The array list becomes: [6, 12, 11, 8, 14, 9, 13, 5, 7, 10]
[6, 12, 11, 8, 14, 9, 13, 5, 7, 10]
> java Seven 10 5 15
Current array list: []
Randomly we select 10 and we keep it. The array list becomes: [10]
Randomly we look at: 10 but we can't accept it. The array list remains: [10]
Randomly we select 11 and we keep it. The array list becomes: [10, 11]
Randomly we look at: 10 but we can't accept it. The array list remains: [10, 11]
Randomly we select 8 and we keep it. The array list becomes: [10, 11, 8]
Randomly we select 5 and we keep it. The array list becomes: [10, 11, 8, 5]
Randomly we select 7 and we keep it. The array list becomes: [10, 11, 8, 5, 7]
Randomly we look at: 8 but we can't accept it. The array list remains: [10, 11, 8, 5, 7]
Randomly we select 9 and we keep it. The array list becomes: [10, 11, 8, 5, 7, 9]
Randomly we look at: 8 but we can't accept it. The array list remains: [10, 11, 8, 5, 7, 9]
Randomly we select 12 and we keep it. The array list becomes: [10, 11, 8, 5, 7, 9, 12]
Randomly we look at: 8 but we can't accept it. The array list remains: [10, 11, 8, 5, 7, 9, 12]
Randomly we select 6 and we keep it. The array list becomes: [10, 11, 8, 5, 7, 9, 12, 6]
Randomly we look at: 5 but we can't accept it. The array list remains: [10, 11, 8, 5, 7, 9, 12, 6]
Randomly we look at: 12 but we can't accept it. The array list remains: [10, 11, 8, 5, 7, 9, 12, 6]
Randomly we look at: 8 but we can't accept it. The array list remains: [10, 11, 8, 5, 7, 9, 12, 6]
Randomly we look at: 5 but we can't accept it. The array list remains: [10, 11, 8, 5, 7, 9, 12, 6]
Randomly we look at: 9 but we can't accept it. The array list remains: [10, 11, 8, 5, 7, 9, 12, 6]
Randomly we look at: 10 but we can't accept it. The array list remains: [10, 11, 8, 5, 7, 9, 12, 6]
Randomly we look at: 5 but we can't accept it. The array list remains: [10, 11, 8, 5, 7, 9, 12, 6]
Randomly we look at: 12 but we can't accept it. The array list remains: [10, 11, 8, 5, 7, 9, 12, 6]
Randomly we look at: 9 but we can't accept it. The array list remains: [10, 11, 8, 5, 7, 9, 12, 6]
Randomly we look at: 12 but we can't accept it. The array list remains: [10, 11, 8, 5, 7, 9, 12, 6]
Randomly we look at: 12 but we can't accept it. The array list remains: [10, 11, 8, 5, 7, 9, 12, 6]
Randomly we look at: 6 but we can't accept it. The array list remains: [10, 11, 8, 5, 7, 9, 12, 6]
Randomly we look at: 11 but we can't accept it. The array list remains: [10, 11, 8, 5, 7, 9, 12, 6]
Randomly we look at: 7 but we can't accept it. The array list remains: [10, 11, 8, 5, 7, 9, 12, 6]
Randomly we look at: 8 but we can't accept it. The array list remains: [10, 11, 8, 5, 7, 9, 12, 6]
Randomly we look at: 11 but we can't accept it. The array list remains: [10, 11, 8, 5, 7, 9, 12, 6]
Randomly we look at: 5 but we can't accept it. The array list remains: [10, 11, 8, 5, 7, 9, 12, 6]
Randomly we select 14 and we keep it. The array list becomes: [10, 11, 8, 5, 7, 9, 12, 6, 14]
Randomly we look at: 9 but we can't accept it. The array list remains: [10, 11, 8, 5, 7, 9, 12, 6, 14]
Randomly we look at: 11 but we can't accept it. The array list remains: [10, 11, 8, 5, 7, 9, 12, 6, 14]
Randomly we look at: 7 but we can't accept it. The array list remains: [10, 11, 8, 5, 7, 9, 12, 6, 14]
Randomly we select 13 and we keep it. The array list becomes: [10, 11, 8, 5, 7, 9, 12, 6, 14, 13]
[10, 11, 8, 5, 7, 9, 12, 6, 14, 13]


 */