diff --git a/TP_DEV3.2/Arbres/Repertoires.java b/TP_DEV3.2/Arbres/Repertoires.java new file mode 100644 index 0000000..f99e301 --- /dev/null +++ b/TP_DEV3.2/Arbres/Repertoires.java @@ -0,0 +1,73 @@ +import java.io.File; +import java.util.ArrayList; +import java.util.List; + + +public class Repertoires { + + +String name; +List children = new ArrayList<>(); + +public Node(String name){ + + this.name=name; + +} + +public addChild(Node child){ + +children.add(child); + +} + +public afficher(String nom){ + + System.out.println(nom+name); + + for(Node c : children){ + + c.print(nom+""); + + } + + +} +public static Node build(File f){ + +Node n = new Node(file.getName()); +File[] list = f.listFiles(); +if(list!=null){ + +for(File child : list){ + + n.addChild(build(child)); +} + +} + +return n; + + + +} + + +public static void main(String[] args) { + +File fichier = New File(args[0]); +Node tree = build(Dictionnaire); + +tree.afficher(""); + + + + + +} + + + + + +} \ No newline at end of file diff --git a/TP_DEV3.2/Repertoires.java b/TP_DEV3.2/Repertoires.java new file mode 100644 index 0000000..f99e301 --- /dev/null +++ b/TP_DEV3.2/Repertoires.java @@ -0,0 +1,73 @@ +import java.io.File; +import java.util.ArrayList; +import java.util.List; + + +public class Repertoires { + + +String name; +List children = new ArrayList<>(); + +public Node(String name){ + + this.name=name; + +} + +public addChild(Node child){ + +children.add(child); + +} + +public afficher(String nom){ + + System.out.println(nom+name); + + for(Node c : children){ + + c.print(nom+""); + + } + + +} +public static Node build(File f){ + +Node n = new Node(file.getName()); +File[] list = f.listFiles(); +if(list!=null){ + +for(File child : list){ + + n.addChild(build(child)); +} + +} + +return n; + + + +} + + +public static void main(String[] args) { + +File fichier = New File(args[0]); +Node tree = build(Dictionnaire); + +tree.afficher(""); + + + + + +} + + + + + +} \ No newline at end of file