chapter_003/src/main/java/ru/job4j/sort/Department.java
/**
     * Add subdivision in directory.
     * @param subdivision - subdivision.
     */
Add subdivision in directory.
@param subdivision - subdivision.
Add subdivision in directory . @param subdivision - subdivision .
public void addSubdivision(String subdivision) {
        char[] variants = subdivision.toCharArray();
        String result = String.valueOf(variants[0]);
        for (int x = 1; x < variants.length; x++) {
            if (variants[x] == '\\' && !directory.contains(result)) {
                this.directory.add(result);
            }
            result = result + String.valueOf(variants[x]);
            if (variants.length == x + 1 && !directory.contains(result)) {
                this.directory.add(result);
            }
        }
    }
public void addSubdivision ( String subdivision ) { char [ ] variants = subdivision . toCharArray ( ) ; String result = String . valueOf ( variants [ 0 ] ) ; for ( int x = 1 ; x < variants . length ; x ++ ) { if ( variants [ x ] == '\\' && ! directory . contains ( result ) ) { this . directory . add ( result ) ; } result = result + String . valueOf ( variants [ x ] ) ; if ( variants . length == x + 1 && ! directory . contains ( result ) ) { this . directory . add ( result ) ; } } }
Add subdivision in directory.
Add subdivision in directory .