Advertisement
Randomsurpriseguy

Listen Prototyp

Feb 1st, 2018
375
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. class IntList{
  2. private int a;
  3. private IntList LE;
  4. private IntList RI;
  5.  
  6. private static int Pointer=0;
  7.  
  8. IntList(int A, IntList B,IntList C){
  9. a=A;
  10. LE=B;
  11. RI=C;
  12. }
  13.  
  14. IntList(int A){
  15. a=A;
  16. LE=null;
  17. RI=null;
  18. }
  19.  
  20. IntList getnext() {
  21. return RI;
  22. }
  23.  
  24. void add(int In) {
  25. IntList Neu=new IntList(In,null,this);
  26. while (RI!=null) {
  27. this.next();
  28. }
  29. this.RI=Neu;
  30. }
  31.  
  32. void next() {
  33. IntList Temp=this;
  34. a=RI.get();
  35. LE=Temp;
  36. RI=RI.getnext();
  37.  
  38. }
  39.  
  40. IntList copyof() {
  41. IntList Out=new IntList(this.a,this.LE,this.RI);
  42. return Out;
  43. }
  44.  
  45. public static IntList Zero=new IntList(0,null,null);
  46.  
  47. int get() {
  48. return a;
  49. }
  50.  
  51. int get(int Z) {
  52. IntList Frag=this.copyof();
  53. while (Z>0) {
  54. Frag=Frag.getnext();
  55. Z--;
  56. }
  57. return Frag.get();
  58. }
  59.  
  60. }
  61.  
  62.  
  63.  
  64. public class ListeTest {
  65.  
  66. public static void main(String[] args) {
  67. // TODO Auto-generated method stub
  68. IntList L=new IntList(1);
  69. L.add(2);
  70. L.add(3);
  71. L.add(4);
  72. System.out.print(L.get());
  73. System.out.print(L.get(1));
  74. }
  75.  
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement