Compare commits

...

2 Commits

Author SHA1 Message Date
EmmanuelTiamzon
a84be66f0f TP6 arbres 2026-01-14 17:29:39 +01:00
EmmanuelTiamzon
5cdf5f602b TP6 2026-01-14 17:03:57 +01:00
8 changed files with 67 additions and 0 deletions

View File

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

View File

@@ -0,0 +1,16 @@
public class Noeud {
private ArrayList<Noeud> fils;
private File noeud;
public Noeud(File noeud) {
this.fils = null;
this.noeud = noeud;
}
// Par polymorphisme et redéfinition on prend la valeur et les fils
public Noeud(ArrayList<Noeud> fils, File noeud) {
this.fils = fils;
this.noeud = noeud;
}
}

View File

@@ -0,0 +1,43 @@
import java.io.File;
public class Repertoires {
private File val;
private Noeud son;
public Repertoires(File root) {
try {
if(!root.isDirectory()) {
this.val = root;
} else {
this.son = new Noeud();
this.val = root;
try {
for(File files : root.listFiles()) {
this.son.add(new Repertoires(files));
}
}catch(SecurityException e2) {
System.err.println("access to read the directory was denied : "+e2);
}
}
} catch(SecurityException e1) {
System.err.println("the file you gave is not a directory : "+e1);
}
}
/*
public void fileToString() {
String stringFile = "";
for(int i = 0; i != file.getName().length(); i++) {
stringFile = ""+file.getPath();
}
return stringFile;
}
*/
public static void main(String[] args) {
Repertoires file = new Repertoires(new File(args[0]));
}
}