Maj du git depuis la derniere fois
This commit is contained in:
39
TP_DEV3.2/Arbres/Prefixe.java
Normal file
39
TP_DEV3.2/Arbres/Prefixe.java
Normal 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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user