29 Novembre
This commit is contained in:
BIN
DEV3.2/TP7/Prefixe/Main.class
Normal file
BIN
DEV3.2/TP7/Prefixe/Main.class
Normal file
Binary file not shown.
24
DEV3.2/TP7/Prefixe/Main.java
Normal file
24
DEV3.2/TP7/Prefixe/Main.java
Normal file
@@ -0,0 +1,24 @@
|
||||
import java.util.*;
|
||||
|
||||
public class Main {
|
||||
|
||||
protected static ArrayDeque<String> pile;
|
||||
|
||||
public static void main(String[] args) {
|
||||
Main.pile = new ArrayDeque(args.length);
|
||||
|
||||
for (int i=0; i<args.length; i++){
|
||||
Main.pile.push(args[i]);
|
||||
}
|
||||
|
||||
Noeud noeudDeb;
|
||||
String debutArbre = Main.pile.pop();
|
||||
if (debutArbre.equals("+")||debutArbre.equals("-")||debutArbre.equals("x")||debutArbre.equals("/")){
|
||||
noeudDeb = new NoeudOperation(debutArbre);
|
||||
}
|
||||
else{
|
||||
noeudDeb = new NoeudChiffre(debutArbre);
|
||||
}
|
||||
noeudDeb.afficherNoeud();
|
||||
}
|
||||
}
|
BIN
DEV3.2/TP7/Prefixe/Noeud.class
Normal file
BIN
DEV3.2/TP7/Prefixe/Noeud.class
Normal file
Binary file not shown.
8
DEV3.2/TP7/Prefixe/Noeud.java
Normal file
8
DEV3.2/TP7/Prefixe/Noeud.java
Normal file
@@ -0,0 +1,8 @@
|
||||
public class Noeud{
|
||||
protected String val;
|
||||
protected Noeud noeudGauche;
|
||||
protected Noeud noeudDroit;
|
||||
|
||||
protected void afficherNoeud(){
|
||||
}
|
||||
}
|
BIN
DEV3.2/TP7/Prefixe/NoeudChiffre.class
Normal file
BIN
DEV3.2/TP7/Prefixe/NoeudChiffre.class
Normal file
Binary file not shown.
11
DEV3.2/TP7/Prefixe/NoeudChiffre.java
Normal file
11
DEV3.2/TP7/Prefixe/NoeudChiffre.java
Normal file
@@ -0,0 +1,11 @@
|
||||
public class NoeudChiffre extends Noeud{
|
||||
|
||||
public NoeudChiffre(String n){
|
||||
this.val = n;
|
||||
}
|
||||
|
||||
protected void afficherNoeud(){
|
||||
System.out.print(val+" ");
|
||||
}
|
||||
|
||||
}
|
BIN
DEV3.2/TP7/Prefixe/NoeudOperation.class
Normal file
BIN
DEV3.2/TP7/Prefixe/NoeudOperation.class
Normal file
Binary file not shown.
21
DEV3.2/TP7/Prefixe/NoeudOperation.java
Normal file
21
DEV3.2/TP7/Prefixe/NoeudOperation.java
Normal file
@@ -0,0 +1,21 @@
|
||||
public class NoeudOperation extends Noeud{
|
||||
|
||||
public NoeudOperation(String ope){
|
||||
this.val = ope;
|
||||
for(int i=0;i<2;i++){
|
||||
String prochainNoeud = Main.pile.pop();
|
||||
if (prochainNoeud.equals("+")||prochainNoeud.equals("-")||prochainNoeud.equals("x")||prochainNoeud.equals("/")){
|
||||
this.noeudGauche = new NoeudOperation(prochainNoeud);
|
||||
}
|
||||
else{
|
||||
this.noeudGauche = new NoeudChiffre(prochainNoeud);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void afficherNoeud(){
|
||||
System.out.print(val+" ");
|
||||
this.noeudGauche.afficherNoeud();
|
||||
this.noeudDroit.afficherNoeud();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user