package ru.job4j.simpleSet;

import com.sun.xml.internal.fastinfoset.util.DuplicateAttributeVerifier;
import org.codehaus.classworlds.DuplicateRealmException;
import org.codehaus.plexus.DuplicateChildContainerException;
import ru.job4j.simpeArray.SimpleArray;

import java.util.DuplicateFormatFlagsException;

public class SimpleSet<E> {

   public SimpleArray<E> simpleArray;
    private int index = 0;

    public SimpleSet() {
        this.simpleArray = new SimpleArray<>();
    }

    public void add(E value) {
        int result = 0;
        for (E element : simpleArray.arrayList) {
            if (value == element) {
                result = 1;
                break;
            }
        }
        if (result == 0) {
            simpleArray.add(value);
        } else {
            throw new DuplicateFormatFlagsException(value.toString());
        }
    }
}

@@ -373,17 +373,16 @@
 ray;%0A   
- 
 private 
@@ -396,16 +396,16 @@
 ex = 0;%0A
+
 %0A    pub
@@ -492,16 +492,24 @@
 lic 
-void add
+boolean contains
 (E v
@@ -524,19 +524,23 @@
         
-int
+boolean
  result 
@@ -541,17 +541,21 @@
 esult = 
-0
+false
 ;%0A      
@@ -663,9 +663,12 @@
 t = 
-1
+true
 ;%0A  
@@ -724,62 +724,61 @@
     
-if (result == 0) %7B%0A            simpleArray.
+return result;%0A    %7D%0A%0A%0A    public void 
 add(
+E 
 value)
-;
+ %7B
 %0A   
@@ -786,85 +786,65 @@
     
-%7D else %7B%0A            throw new DuplicateFormatFlagsException(value.toString()
+if (!contains(value)) %7B%0A            simpleArray.add(value
 );%0A 

task #996