Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 7th, 2012  |  syntax: None  |  size: 1.09 KB  |  hits: 9  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. package gnoma;
  2.  
  3. public class nodo {
  4.  
  5. private String valor = null;
  6. private nodo siguiente = null;
  7. private int desorden;
  8.  
  9. public nodo(){
  10.  
  11.     this.valor=null;
  12.     this.siguiente=null;
  13. }
  14.  
  15. public nodo(String elemento, nodo next){
  16.  
  17.     this.valor = elemento;
  18.     this.siguiente = next;
  19.     this.desorden();
  20. }
  21.  
  22. public int getDesorden(){
  23.  
  24.     return desorden;
  25. }
  26. public nodo(String elemento){
  27.  
  28.     this.valor = elemento;
  29.     this.siguiente = null;
  30.     this.desorden();
  31. }
  32.  
  33. public void setValor(String elemento){
  34.  
  35.     this.valor = elemento;
  36. }
  37.  
  38. public void setSiguiente(nodo next){
  39.  
  40.     this.siguiente = next;
  41. }
  42.  
  43. public void setDesorden(int desorden){
  44.  
  45.     this.desorden=desorden;
  46. }
  47.  
  48. public String getValor(){
  49.  
  50.     return this.valor;
  51. }
  52.  
  53. public nodo getSiguiente(){
  54.  
  55.     return this.siguiente;
  56. }
  57.  
  58. public void desorden(){
  59.  
  60.     int desor=0,i,j;
  61.     int largo = this.valor.length();
  62.     for(i=0;i<largo;i++){
  63.         for(j=i;j<largo;j++){
  64.             if(this.valor.charAt(i)>this.valor.charAt(j))
  65.                 desor++;
  66.         }
  67.     }
  68.     this.desorden=desor;
  69. }
  70. }