Advertisement
Guest User

codigo

a guest
May 20th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.29 KB | None | 0 0
  1. package Lista;
  2.  
  3. public class Pessoa {
  4. private String nome;
  5. private Pessoa proximo;
  6. private Pessoa anterior;
  7.  
  8. public Pessoa(String nome){
  9. this.nome = nome;
  10. }
  11.  
  12. public String getNome() {
  13. return nome;
  14. }
  15.  
  16. public void setNome(String nome) {
  17. this.nome = nome;
  18. }
  19.  
  20.  
  21.  
  22. public Pessoa getProximo() {
  23. return proximo;
  24. }
  25.  
  26. public void setProximo(Pessoa proximo) {
  27. this.proximo = proximo;
  28. }
  29.  
  30. public Pessoa getAnterior() {
  31. return anterior;
  32. }
  33.  
  34. public void setAnterior(Pessoa anterior) {
  35. this.anterior = anterior;
  36. }
  37.  
  38. @Override
  39. public String toString(){
  40. return "["+this.nome+"]";
  41. }
  42.  
  43. }
  44.  
  45.  
  46. package Lista;
  47.  
  48. public class Test {
  49.  
  50. public static void main(String args[]){
  51.  
  52. Pessoa JhonSnow = new Pessoa("Jhon Snow");
  53. Pessoa Danerys = new Pessoa("Danerys");
  54. Pessoa Ayra = new Pessoa("Ayra");
  55. Pessoa Sansa = new Pessoa("Sansa");
  56. Pessoa Drogon = new Pessoa("Drogon");
  57. Pessoa Tirion = new Pessoa("Tirion");
  58. Pessoa Varys = new Pessoa("Varys");
  59.  
  60. Ayra.setProximo(Sansa);
  61. Sansa.setAnterior(Ayra);
  62. Sansa.setProximo(Drogon);
  63. Drogon.setAnterior(Sansa);
  64.  
  65. //[Ayra]<->[Sansa]<->[Drogon]
  66. // Varys
  67. sansa drgon
  68. Varys.setProximo(Ayra.getProximo().getProximo());
  69. Ayra.getProximo().getProximo(
  70. -).setAnterior(Varys);
  71.  
  72. Ayra.getProximo().setProximo(Varys);
  73.  
  74. [A]<-->[C]<-->[F]<-->[L]
  75. ADD B
  76. B.setProximo(A.getProximo())
  77. [A]<-->[C]<-->[F]<-->[L]
  78. [B]--->[C]
  79. B.setAnterior(A)
  80. [A]<-->[C]<-->[F]<-->[L]
  81. [A]<---[B]--->[C]
  82. A.setProximo(B)
  83. [A]<---[C]<-->[F]<-->[L]
  84. [A]<-->[B]--->[C]
  85. B C
  86. A.getProximo().getProximo().setAnterior(B)
  87. [A]<--->[B]<--->[C]<-->[F]<-->[L]
  88. ADD G
  89. B C F L
  90. G.setProximo(A.gP().gP().gP().gP())
  91. [A]<--->[B]<--->[C]<-->[F]<-->[L]
  92. [G]--->[L] B C F
  93. G.setAnterior(A.gP().gP().gP())
  94. [A]<--->[B]<--->[C]<-->[F]<-->[L]
  95. [F]<----[G]---->[L]
  96. B C F
  97. A.gP().gP().gP().setProximo(G)
  98. [A]<--->[B]<--->[C]<-->[F]<----[L]
  99. [F]<--->[G]---->[L]
  100. B C F G L
  101. A.gP().gP().gP().gP().gP().setAnterior(G)
  102.  
  103.  
  104. }
  105.  
  106. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement