29 Novembre

This commit is contained in:
2023-11-29 17:27:03 +01:00
parent fae1f4c4c5
commit 9a4e1c622e
28 changed files with 355 additions and 0 deletions

Binary file not shown.

View File

@@ -0,0 +1,8 @@
import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args){
Repertoires main = new Repertoires(args[0]);
}
}

Binary file not shown.

View File

@@ -0,0 +1,62 @@
import java.io.*;
import java.util.*;
public class Noeud{
private File f;
private Noeud n1=null;
private Noeud n2=null;
private Noeud n3=null;
private Noeud n4=null;
public Noeud(File s){
this.f = s;
}
/*public Noeud(String s, Noeud noeud1){java.io.File
}
public Noeud(String s, Noeud noeud1, Noeud noeud2, Noeud noeud3){
this.f = new File(s);
this.noeud1=n1;
this.noeud2=n2;
this.noeud3=n3;
}
public Noeud(String s, Noeud noeud1, Noeud noeud2, Noeud noeud3, Noeud noeud4){
this.f = new File(s);
this.noeud1=n1;
this.noeud2=n2;
this.noeud3=n3;
this.noeud4=n4;
}*/
public void add(Noeud n){
if(n1!=null){
if(n2!=null){
if(n3!=null){
n4=n;
return;
}
n3=n;
return;
}
n2=n;
return;
}
n1=n;
return;
}
public File getFile(){
return this.f;
}
public Noeud getN1(){
return this.n1;
}
public Noeud getN2(){
return this.n2;
}
public Noeud getN3(){
return this.n3;
}
public Noeud getN4(){
return this.n4;
}
}

Binary file not shown.

View File

@@ -0,0 +1,50 @@
import java.io.*;
import java.util.*;
public class Repertoires{
public Repertoires(String s){
File f = new File(s);
ArrayDeque<File> a = new ArrayDeque<File>();
a.add(f);
Noeud n=this.tree(a);
this.afficher(n,0);
}
public Noeud tree(ArrayDeque<File> a){
File f = a.remove();
if(f.isFile()){
Noeud n = new Noeud(f);
return n;
}
if(f.isDirectory()){
Noeud n = new Noeud(f);
File[] liste = f.listFiles();
for(int i=0;i<liste.length;i++){
a.add(liste[i]);
Noeud m=this.tree(a);
n.add(m);
}
return n;
}
return null;
}
public void afficher(Noeud n,int i){
String chaine="";
for(int j=0;j<i;j++){
chaine = chaine+" ";
}
chaine = chaine+n.getFile().getName();
System.out.println(chaine);
if(n.getN1()!=null){
afficher(n.getN1(),i+1);
if(n.getN2()!=null){
afficher(n.getN2(),i+1);
if(n.getN3()!=null){
afficher(n.getN3(),i+1);
if(n.getN4()!=null){
afficher(n.getN4(),i+1);
}
}
}
}
}
}

View File