Advertisement
Guest User

Untitled

a guest
May 28th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.62 KB | None | 0 0
  1. public void ajouterNoeud(Noeud ns, Noeud ns2){
  2.         if(ns2 == STOP){ //STOP est le noeud de findemot c'est un attribut de classe
  3.             ns.getEnfant().addFirst(ns2);
  4.             ns2.setParent(ns);
  5.         }else{
  6.             if(ns.getEnfant().isEmpty()){
  7.                 ns.getEnfant().add(ns2);
  8.                 ns2.setParent(ns);
  9.                
  10.             }
  11.             else{
  12.                 int taille = ns.getEnfant().size();
  13.                 boolean dejapresent = false;
  14.                 for(int i = 0;i<taille;i++){
  15.                     if(ns.getEnfant().get(i).getLettre()==ns2.getLettre()){
  16.                         dejapresent = true;
  17.                     }
  18.                 }
  19.                 if(dejapresent == false){
  20.                     ns.getEnfant().add(ns2);
  21.                     ns2.setParent(ns);
  22.                    
  23.                 }
  24.             }
  25.         }
  26.    
  27.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement