Maj du git depuis la derniere fois

This commit is contained in:
2025-11-27 13:53:52 +01:00
parent ffdd031bc1
commit 6f13bae4f8
18 changed files with 1838 additions and 74 deletions

BIN
TP_DEV3.2/Arbres/Node.class Normal file

Binary file not shown.

View File

@@ -0,0 +1,50 @@
import java.io.File;
import java.util.ArrayList;
import java.util.List;
public class Node {
String name;
List<Node> children = new ArrayList<>();
public Node(String name){
this.name = name;
}
public void addChild(Node child){
children.add(child);
}
public void afficher(String indent){
System.out.println(indent + name);
for(Node c : children){
c.afficher(indent + " "); // indentation augmentée
}
}
public static Node build(File f){
Node n = new Node(f.getName());
File[] list = f.listFiles();
if(list != null){
for(File child : list){
n.addChild(build(child)); // récursion OK
}
}
return n;
}
public static void main(String[] args) {
if(args.length != 1){
System.out.println("Usage : java Node <repertoire>");
return; // éviter un crash
}
File fichier = new File(args[0]);
Node tree = build(fichier);
tree.afficher("");
}
}

View File

@@ -0,0 +1,39 @@
public class Prefixe {
String value;
Prefixe left;
Prefixe right;
public Prefixe(String v) {
this.value = v;
}
public boolean isOperator() {
return "+-*/".contains(value);
}
public static int index = 0;
public static Prefixe build(String[] t) {
String token = t[index++];
Prefixe p = new Prefixe(token);
if (p.isOperator()) {
p.left = build(t);
p.right = build(t);
}
return p;
}
}

View File

@@ -27,7 +27,7 @@ public afficher(String nom){
for(Node c : children){
c.print(nom+"");
c.print(nom+" ");
}

View File

@@ -1,73 +0,0 @@
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("");
}
}