Advertisement
Guest User

Untitled

a guest
Feb 28th, 2015
323
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 25.85 KB | None | 0 0
  1.  
  2. public class LInfiniteInteger implements InfiniteIntegerInterface
  3. {
  4.     private Node firstNode;
  5.     private Node lastNode;
  6.         private Node middleNode;
  7.         private int middlePosition;
  8.     private int numberOfDigits;
  9.     private boolean isNegative;
  10.    
  11.     /**
  12.      * Constructor: Constructs this infinite integer from a string
  13.      * representing an integer.
  14.      * @param s  a string represents an integer
  15.      */
  16.     public LInfiniteInteger(String s)
  17.     {
  18.         // TO DO
  19.             int newDigit = 0;
  20.             isNegative = false;
  21.             numberOfDigits = 0;
  22.             middlePosition = 0;
  23.             firstNode = null;
  24.             middleNode = null;
  25.             lastNode = null;
  26.             for(int i = 0; i < s.length(); i++)
  27.             {
  28.                 newDigit = (int)s.charAt(i) - 48;
  29.                 if((newDigit >= 0) && (newDigit <= 9))
  30.                 {
  31.                     this.add(newDigit);
  32.                 }
  33.                 else if((newDigit == ((int)'-') - 48))
  34.                     isNegative = true;
  35.             }
  36.     }
  37.  
  38.     /**
  39.      * Constructor: Constructs this infinite integer from an integer.
  40.      * @param anInteger  an integer
  41.      */
  42.     public LInfiniteInteger(int anInteger)
  43.     {
  44.         // TO DO
  45.             isNegative = false;
  46.             numberOfDigits = 0;
  47.             middlePosition = 0;
  48.             firstNode = null;
  49.             middleNode = null;
  50.             lastNode = null;
  51.             if(anInteger < 0)
  52.             {
  53.                 isNegative = true;
  54.                 anInteger = -1 * anInteger;
  55.             }
  56.             //while(anInteger > 0)
  57.             //{
  58.                 //this.add(anInteger % 10);
  59.                 //anInteger = anInteger / 10;
  60.             //}
  61.             while(anInteger > 0)
  62.             {
  63.                 this.addToFront(anInteger % 10);
  64.                 anInteger = anInteger / 10;
  65.             }
  66.            
  67.     }
  68.  
  69.     /**
  70.      * Gets the number of digits of this infinite integer.
  71.      * @return an integer representing the number of digits
  72.      * of this infinite integer.
  73.      */
  74.     public int getNumberOfDigits()
  75.     {
  76.         // TO DO
  77.             removeExtraZeros(this);
  78.             return numberOfDigits;
  79.     }
  80.  
  81.     /**
  82.      * Checks whether this infinite integer is a negative number.
  83.      * @return true if this infinite integer is a negative number.
  84.      * Otherwise, return false.
  85.      */
  86.     public boolean isNegative()
  87.     {
  88.         // TO DO
  89.             return isNegative;
  90.     }
  91.  
  92.     /**
  93.      * Calculates the result of this infinite integer plus anInfiniteInteger
  94.      * @param anInfiniteInteger the infinite integer to be added to this
  95.      * infinite integer.
  96.      * @return a NEW infinite integer representing the result of this
  97.      * infinite integer plus anInfiniteInteger
  98.      */
  99.     public InfiniteIntegerInterface plus(final InfiniteIntegerInterface anInfiniteInteger)
  100.     {      
  101.         // TO DO
  102.             int carry = 0;
  103.             int tempResult = 0;
  104.             boolean resultIsNegative = false;
  105.             LInfiniteInteger firstOperand = new LInfiniteInteger(this.toString());
  106.             LInfiniteInteger secondOperand = new LInfiniteInteger(anInfiniteInteger.toString());
  107.             LInfiniteInteger returnResult = new LInfiniteInteger("");
  108.             Node currentOne = firstOperand.lastNode;
  109.             Node currentTwo = secondOperand.lastNode;
  110.             if((firstOperand.isNegative == true) && (secondOperand.isNegative == true))
  111.             {
  112.                 firstOperand.isNegative = false;
  113.                 secondOperand.isNegative = false;
  114.                 LInfiniteInteger tempReturnResult = new LInfiniteInteger(firstOperand.plus(secondOperand).toString());
  115.                 Node currentOneInner = tempReturnResult.firstNode;
  116.                 while(currentOneInner != null)
  117.                 {
  118.                     returnResult.add(currentOneInner.data);
  119.                     currentOneInner = currentOneInner.next;
  120.                 }
  121.                 returnResult.isNegative = true;
  122.                 //removeExtraZeros(returnResult); //problem
  123.                 return returnResult;
  124.             }
  125.             else if((firstOperand.isNegative == true) && (secondOperand.isNegative == false))
  126.             {
  127.                 if(firstOperand.compareMag(secondOperand) == 1)
  128.                 {
  129.                     firstOperand.isNegative = false;
  130.                     LInfiniteInteger tempReturnResult = new LInfiniteInteger(firstOperand.minus(secondOperand).toString());
  131.                     Node currentOneInner = tempReturnResult.firstNode;
  132.                     while(currentOneInner != null)
  133.                     {
  134.                         returnResult.add(currentOneInner.data);
  135.                         currentOneInner = currentOneInner.next;
  136.                     }
  137.                     returnResult.isNegative = true;
  138.                     return returnResult;
  139.                 }
  140.                 else if(firstOperand.compareMag(secondOperand) == 0)
  141.                 {
  142.                     returnResult.add(0);
  143.                     return returnResult;
  144.                 }
  145.                 else
  146.                 {
  147.                     firstOperand.isNegative = false;
  148.                     LInfiniteInteger tempReturnResult = new LInfiniteInteger(secondOperand.minus(firstOperand).toString());
  149.                     Node currentOneInner = tempReturnResult.firstNode;
  150.                     while(currentOneInner != null)
  151.                     {
  152.                         returnResult.add(currentOneInner.data);
  153.                         currentOneInner = currentOneInner.next;
  154.                     }
  155.                     return returnResult;
  156.                 }
  157.             }
  158.             else if((firstOperand.isNegative == false) && (secondOperand.isNegative == true))
  159.             {
  160.                 if(firstOperand.compareMag(secondOperand) == 1)
  161.                 {
  162.                     secondOperand.isNegative = false;
  163.                     LInfiniteInteger tempReturnResult = new LInfiniteInteger(firstOperand.minus(secondOperand).toString());
  164.                     Node currentOneInner = tempReturnResult.firstNode;
  165.                     while(currentOneInner != null)
  166.                     {
  167.                         returnResult.add(currentOneInner.data);
  168.                         currentOneInner = currentOneInner.next;
  169.                     }
  170.                     return returnResult;
  171.                 }
  172.                 else if(firstOperand.compareMag(secondOperand) == 0)
  173.                 {
  174.                     returnResult.add(0);
  175.                     return returnResult;
  176.                 }
  177.                 else
  178.                 {
  179.                     secondOperand.isNegative = false;
  180.                     LInfiniteInteger tempReturnResult = new LInfiniteInteger(secondOperand.minus(firstOperand).toString());
  181.                     Node currentOneInner = tempReturnResult.firstNode;
  182.                     while(currentOneInner != null)
  183.                     {
  184.                         returnResult.add(currentOneInner.data);
  185.                         currentOneInner = currentOneInner.next;
  186.                     }
  187.                     returnResult.isNegative = true;
  188.                     return returnResult;
  189.                 }
  190.             }
  191.             else
  192.             {
  193.                 while((currentOne != null) && (currentTwo != null))
  194.                 {
  195.                     tempResult = currentOne.data + currentTwo.data + carry;
  196.                     returnResult.addToFront((tempResult % 10));
  197.                     //result = (tempResult % 10) + result;
  198.                     carry = tempResult/10;
  199.                     currentOne = currentOne.previous;
  200.                     currentTwo = currentTwo.previous;
  201.                 }
  202.                 if(currentOne == null)
  203.                 {
  204.                     while(currentTwo != null)
  205.                     {
  206.                         tempResult = currentTwo.data + carry;
  207.                         //result = (tempResult % 10) + result;
  208.                         returnResult.addToFront((tempResult % 10));
  209.                         carry = tempResult/10;
  210.                     }
  211.                 }
  212.                 else if(currentTwo == null)
  213.                 {
  214.                     while(currentOne != null)
  215.                     {
  216.                         tempResult = currentOne.data + carry;
  217.                         //result = (tempResult % 10) + result;
  218.                         returnResult.addToFront((tempResult % 10));
  219.                         carry = tempResult/10;
  220.                     }
  221.                 }
  222.                 //result = carry + result;
  223.                 if(carry > 0)
  224.                 {
  225.                     returnResult.addToFront((carry));
  226.                 }
  227.                
  228.                 //LInfiniteInteger returnResult = new LInfiniteInteger(result);
  229.                 removeExtraZeros(returnResult);
  230.                 return returnResult;
  231.             }
  232.     }
  233.     /**
  234.      * Calculates the result of this infinite integer subtracted by anInfiniteInteger
  235.      * @param anInfiniteInteger the infinite integer to subtract.
  236.      * @return a NEW infinite integer representing the result of this
  237.      * infinite integer subtracted by anInfiniteInteger
  238.      */
  239.     public InfiniteIntegerInterface minus(final InfiniteIntegerInterface anInfiniteInteger)
  240.     {
  241.         // TO DO
  242.             LInfiniteInteger firstOperand = new LInfiniteInteger(this.toString());
  243.             LInfiniteInteger secondOperand = new LInfiniteInteger(anInfiniteInteger.toString());
  244.             LInfiniteInteger returnResult = new LInfiniteInteger("");
  245.             int tempResult;
  246.             boolean resultIsNegative = false;
  247.             Node currentOne = firstOperand.lastNode;
  248.             Node currentTwo = secondOperand.lastNode;
  249.             if((firstOperand.isNegative == false) && (secondOperand.isNegative == false))
  250.             {
  251.                 if(firstOperand.compareMag(secondOperand) == 1)
  252.                 {
  253.                     //algorithm
  254.                     while((currentOne != null) && (currentTwo != null))
  255.                     {
  256.                        
  257.                         if(currentOne.data > currentTwo.data)
  258.                         {
  259.                             tempResult = currentOne.data - currentTwo.data;
  260.                             //result = tempResult + result;
  261.                             returnResult.addToFront(tempResult);
  262.                         }
  263.                         else if(currentOne.data < currentTwo.data)
  264.                         {
  265.                             currentOne.previous.data -= 1;
  266.                             currentOne.data += 10;
  267.                             tempResult = currentOne.data - currentTwo.data;
  268.                             //result = tempResult + result;
  269.                             returnResult.addToFront(tempResult);  
  270.                         }
  271.                     }
  272.                     if(currentOne == null)
  273.                     {
  274.                         while(currentTwo != null)
  275.                         {
  276.                             //result = currentTwo.data + result;
  277.                             returnResult.addToFront(currentTwo.data);
  278.                             currentTwo = currentTwo.previous;
  279.                         }
  280.                     }
  281.                     else if(currentTwo == null)
  282.                     {
  283.                         while(currentTwo != null)
  284.                         {
  285.                             //result = currentTwo.data + result;
  286.                             returnResult.addToFront(currentTwo.data);
  287.                             currentTwo = currentTwo.previous;
  288.                         }
  289.                     }
  290.                     return returnResult;
  291.                 }
  292.                 else if(firstOperand.compareMag(secondOperand) == 0)
  293.                 {
  294.                     returnResult.add(0);
  295.                     return returnResult;
  296.                 }
  297.                 else
  298.                 {
  299.                     LInfiniteInteger tempReturnResult = new LInfiniteInteger(secondOperand.minus(firstOperand).toString());
  300.                     Node currentOneInner = tempReturnResult.firstNode;
  301.                     while(currentOneInner != null)
  302.                     {
  303.                         returnResult.add(currentOneInner.data);
  304.                         currentOneInner = currentOneInner.next;
  305.                     }
  306.                     returnResult.isNegative = true;
  307.                     return returnResult;
  308.                 }
  309.             }
  310.             else if((firstOperand.isNegative == false) && (secondOperand.isNegative == true))
  311.             {
  312.                 secondOperand.isNegative = false;
  313.                 LInfiniteInteger tempReturnResult = new LInfiniteInteger(firstOperand.plus(secondOperand).toString());
  314.                 Node currentOneInner = tempReturnResult.firstNode;
  315.                 while(currentOneInner != null)
  316.                 {
  317.                     returnResult.add(currentOneInner.data);
  318.                     currentOneInner = currentOneInner.next;
  319.                 }
  320.                 return returnResult;
  321.             }
  322.             else if((firstOperand.isNegative == true) && (secondOperand.isNegative == false))
  323.             {
  324.                 firstOperand.isNegative = false;
  325.                 LInfiniteInteger tempReturnResult = new LInfiniteInteger(firstOperand.plus(secondOperand).toString());
  326.                 Node currentOneInner = tempReturnResult.firstNode;
  327.                 while(currentOneInner != null)
  328.                 {
  329.                     returnResult.add(currentOneInner.data);
  330.                     currentOneInner = currentOneInner.next;
  331.                 }
  332.                 returnResult.isNegative = true;
  333.                 return returnResult;
  334.             }
  335.             else
  336.             {
  337.                 if(firstOperand.compareMag(secondOperand) == -1)
  338.                 {
  339.                     firstOperand.isNegative = false;
  340.                     secondOperand.isNegative = false;
  341.                     LInfiniteInteger tempReturnResult = new LInfiniteInteger(firstOperand.minus(secondOperand).toString());
  342.                     Node currentOneInner = tempReturnResult.firstNode;
  343.                     while(currentOneInner != null)
  344.                     {
  345.                         returnResult.add(currentOneInner.data);
  346.                         currentOneInner = currentOneInner.next;
  347.                     }
  348.                     return returnResult;
  349.                 }
  350.                 else if(firstOperand.compareMag(secondOperand) == 0)
  351.                 {
  352.                     returnResult.add(0);
  353.                     return returnResult;
  354.                 }
  355.                 else
  356.                 {
  357.                     firstOperand.isNegative = false;
  358.                     secondOperand.isNegative = false;
  359.                     LInfiniteInteger tempReturnResult = new LInfiniteInteger(firstOperand.minus(secondOperand).toString());
  360.                     Node currentOneInner = tempReturnResult.firstNode;
  361.                     while(currentOneInner != null)
  362.                     {
  363.                         returnResult.add(currentOneInner.data);
  364.                         currentOneInner = currentOneInner.next;
  365.                     }
  366.                     returnResult.isNegative = true;
  367.                     return returnResult;
  368.                 }
  369.             }
  370.            
  371.     }
  372.    
  373.     /**
  374.      * Generates a string representing this infinite integer. If this infinite integer
  375.      * is a negative number a minus symbol should be in the front of numbers. For example,
  376.      * "-12345678901234567890". But if the infinite integer is a positive number, no symbol
  377.      * should be in the front of the numbers (e.g., "12345678901234567890").
  378.      * @return a string representing this infinite integer number.
  379.      */
  380.     public String toString()
  381.     {
  382.         // TO DO
  383.             Node currentNode = firstNode;
  384.             String infiniteIntString = "";
  385.             if(isNegative == true)
  386.             {
  387.                 infiniteIntString = "-";
  388.             }
  389.             while(currentNode != null)
  390.             {
  391.                 infiniteIntString = infiniteIntString + currentNode.data;
  392.                 currentNode = currentNode.next;
  393.             }
  394.             return infiniteIntString;
  395.     }
  396.    
  397.     /**
  398.      * Compares this infinite integer with anInfiniteInteger
  399.      * @return either -1, 0, or 1 as follows:
  400.      * If this infinite integer is less than anInfiniteInteger, return -1.
  401.      * If this infinite integer is equal to anInfiniteInteger, return 0.
  402.      * If this infinite integer is greater than anInfiniteInteger, return 1.
  403.      */
  404.     public int compareTo(InfiniteIntegerInterface anInfiniteInteger)
  405.     {
  406.         // TO DO
  407.             LInfiniteInteger first = new LInfiniteInteger(this.toString());
  408.             LInfiniteInteger second = new LInfiniteInteger(anInfiniteInteger.toString());
  409.             removeExtraZeros(first);
  410.             removeExtraZeros(second);
  411.             if((first.isNegative == true) && (second.isNegative == false))
  412.             {
  413.                 return -1;
  414.             }
  415.             else if((first.isNegative == false) && (second.isNegative == true))
  416.             {
  417.                 return 1;
  418.             }
  419.             else if((first.isNegative == false) && (second.isNegative == false))
  420.             {
  421.                 if(first.numberOfDigits > second.numberOfDigits)
  422.                 {
  423.                  return 1;
  424.                 }
  425.                 else if(first.numberOfDigits < second.numberOfDigits)
  426.                 {
  427.                     return -1;
  428.                 }
  429.                 else
  430.                 {
  431.                     Node currentOne = first.firstNode;
  432.                     Node currentTwo = second.firstNode;
  433.                     while((currentOne != null) && (currentTwo != null))
  434.                     {
  435.                         if(currentOne.data > currentTwo.data)
  436.                         {
  437.                             return 1;
  438.                         }
  439.                         else if(currentOne.data < currentTwo.data)
  440.                         {
  441.                             return -1;
  442.                         }
  443.                         else
  444.                         {
  445.                             currentOne = currentOne.next;
  446.                             currentTwo = currentTwo.next;
  447.                         }
  448.                     }
  449.                 }
  450.             }
  451.             else
  452.             {
  453.                 if(first.numberOfDigits > second.numberOfDigits)
  454.                 {
  455.                     return -1;
  456.                 }
  457.                 else if(first.numberOfDigits < second.numberOfDigits)
  458.                 {
  459.                     return 1;
  460.                 }
  461.                 else
  462.                 {
  463.                     Node currentOne = first.firstNode;
  464.                     Node currentTwo = second.firstNode;
  465.                     while((currentOne != null) && (currentTwo != null))
  466.                     {
  467.                         if(currentOne.data > currentTwo.data)
  468.                         {
  469.                             return -1;
  470.                         }
  471.                         else if(currentOne.data < currentTwo.data)
  472.                         {
  473.                             return 1;
  474.                         }
  475.                         else
  476.                         {
  477.                             currentOne = currentOne.next;
  478.                             currentTwo = currentTwo.next;
  479.                         }
  480.                     }
  481.                     return 0;
  482.                 }
  483.             }
  484.             return 0;
  485.     }
  486.         public int compareMag(InfiniteIntegerInterface anInfiniteInteger)
  487.         {
  488.             LInfiniteInteger first = new LInfiniteInteger(this.toString());
  489.             LInfiniteInteger second = new LInfiniteInteger(anInfiniteInteger.toString());
  490.             removeExtraZeros(first);
  491.             removeExtraZeros(second);
  492.             first.isNegative = false;
  493.             second.isNegative = false;
  494.            
  495.             if(first.numberOfDigits > second.numberOfDigits)
  496.                 {
  497.                  return 1;
  498.                 }
  499.                 else if(first.numberOfDigits < second.numberOfDigits)
  500.                 {
  501.                     return -1;
  502.                 }
  503.                 else
  504.                 {
  505.                     Node currentOne = first.firstNode;
  506.                     Node currentTwo = second.firstNode;
  507.                     while((currentOne != null) && (currentTwo != null))
  508.                     {
  509.                         if(currentOne.data > currentTwo.data)
  510.                         {
  511.                             return 1;
  512.                         }
  513.                         else if(currentOne.data < currentTwo.data)
  514.                         {
  515.                             return -1;
  516.                         }
  517.                         else
  518.                         {
  519.                             currentOne = currentOne.next;
  520.                             currentTwo = currentTwo.next;
  521.                         }
  522.                     }
  523.                 }
  524.             return 0;
  525.         }
  526.     /**
  527.      * Calculates the result of this infinite integer multiplied by anInfiniteInteger
  528.      * @param anInfiniteInteger the multiplier.
  529.      * @return a NEW infinite integer representing the result of this
  530.      * infinite integer multiplied by anInfiniteInteger.
  531.      */
  532.     public InfiniteIntegerInterface multiply(final InfiniteIntegerInterface anInfiniteInteger)
  533.     {
  534.         // TO DO
  535.             int place1 = 0;
  536.             int place2 = 0;
  537.             LInfiniteInteger tempFirstOp = new LInfiniteInteger(this.toString());
  538.             LInfiniteInteger tempSecondOp = new LInfiniteInteger(anInfiniteInteger.toString());
  539.             LInfiniteInteger firstOperand = new LInfiniteInteger("");
  540.             LInfiniteInteger secondOperand = new LInfiniteInteger("");
  541.             LInfiniteInteger result = new LInfiniteInteger("");
  542.             LInfiniteInteger tempResult = new LInfiniteInteger("");
  543.             String tempResultString = "";
  544.             Integer tempResultInt = new Integer(0);
  545.             if((tempFirstOp.compareTo(tempSecondOp) == 1) || (tempFirstOp.compareTo(tempSecondOp) == 0))
  546.             {
  547.                 firstOperand = tempFirstOp;
  548.                 secondOperand = tempSecondOp;
  549.             }
  550.             else
  551.             {
  552.                 firstOperand = tempSecondOp;
  553.                 secondOperand = tempFirstOp;
  554.             }
  555.            
  556.             Node currentTwo = secondOperand.lastNode;
  557.             while(currentTwo != null)
  558.             {
  559.                 place1 = 0;
  560.                 Node currentOne = firstOperand.lastNode;
  561.                 while(currentOne != null)
  562.                 {
  563.                     tempResultInt = currentOne.data * currentTwo.data;
  564.                     tempResultString = tempResultInt.toString();
  565.                     for(int i = 0; i <= (place1 + place2); i++)
  566.                     {
  567.                         tempResultString = tempResultString + "0";
  568.                     }
  569.                     tempResult = new LInfiniteInteger(tempResultString);
  570.                     result.plus(tempResult);
  571.                     place1++;
  572.                     currentOne = currentOne.next;
  573.                 }
  574.                 place2++;
  575.             }
  576.             return result;
  577.     }
  578.         public void add(int newDigit)
  579.     {
  580.         if(firstNode == null)
  581.         {
  582.             firstNode = new Node(null, newDigit, null);
  583.             lastNode = firstNode;
  584.         } //if the list is empty create a new node with newEntry as the data, but no previous or next node
  585.         else
  586.         {
  587.             Node newNode = new Node(lastNode, newDigit, null);
  588.             lastNode.next = newNode;
  589.             lastNode = newNode;
  590.         } //otherwise, (there is at least one node in the list already) add a new node such that "lastNode" is before it, data = neEntry, and there is nothing after it
  591.        
  592.         numberOfDigits++; //either way, add 1 to numberOfDigits
  593.        
  594.         if(numberOfDigits % 2 == 1)
  595.         {
  596.                     if(middleNode == null)
  597.                     {
  598.                         middleNode = firstNode;
  599.                     }// if numberOfDigits is not divisible by 2, and there is no middle node assigned yet, make the middle node equal to first node
  600.                     else
  601.                     {
  602.                         middleNode = middleNode.next;
  603.                     }//if numberOfEntries is not divisible by 2, and there is a middle node assigned, move middle node up one in the chain
  604.                     middlePosition++; // either way, increment the middlePosition variable
  605.         }
  606.     }
  607.         public void addToFront(int newDigit)
  608.         {
  609.             if(firstNode == null)
  610.             {
  611.                 firstNode = new Node(null, newDigit, null);
  612.                 lastNode = firstNode;
  613.             }
  614.             else
  615.             {
  616.                 Node newNode = new Node(null, newDigit, firstNode);
  617.                 firstNode.previous = newNode;
  618.                 firstNode = newNode;
  619.             }
  620.             numberOfDigits++;
  621.             if(numberOfDigits % 2 == 1)
  622.             {
  623.                 if(middleNode == null)
  624.                 {
  625.                     middleNode = firstNode;
  626.                 }// if numberOfDigits is not divisible by 2, and there is no middle node assigned yet, make the middle node equal to first node
  627.                 else
  628.                 {
  629.                     middleNode = middleNode.previous;
  630.                 }//if numberOfEntries is not divisible by 2, and there is a middle node assigned, move middle node up one in the chain
  631.                 middlePosition++; // either way, increment the middlePosition variable
  632.             }
  633.         }
  634.         public void removeExtraZeros(LInfiniteInteger anInfiniteInteger)
  635.         {
  636.             Node currentNode = firstNode;
  637.             while((currentNode.data == 0) && (currentNode.next != null))
  638.             {
  639.                 firstNode = currentNode.next;
  640.                 currentNode = currentNode.next;
  641.                 numberOfDigits--;
  642.             }
  643.         }
  644.    
  645.     private class Node
  646.     {
  647.         private int data;
  648.         private Node next;
  649.         private Node previous;
  650.        
  651.         private Node(Node previousNode, int aData, Node nextNode)
  652.         {
  653.             previous = previousNode;
  654.             data = aData;
  655.             next = nextNode;
  656.         }
  657.        
  658.         private Node(int aData)
  659.         {
  660.             this(null, aData, null);
  661.         }
  662.     }
  663. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement