A perte
This commit is contained in:
73
TP_DEV3.2/Arbres/Repertoires.java
Normal file
73
TP_DEV3.2/Arbres/Repertoires.java
Normal file
@@ -0,0 +1,73 @@
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class Repertoires {
|
||||
|
||||
|
||||
String name;
|
||||
List<Node> 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("");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
73
TP_DEV3.2/Repertoires.java
Normal file
73
TP_DEV3.2/Repertoires.java
Normal file
@@ -0,0 +1,73 @@
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class Repertoires {
|
||||
|
||||
|
||||
String name;
|
||||
List<Node> 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("");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user