import becker.util.Test;
import becker.util.*;

public class ElementNode extends Object
{
  private int row;
  private int col;
  private int value;
  private ElementNode next;

  public ElementNode(int theRow, int theColumn, int theValue)
  {   this.row = theRow;
      this.col = theColumn;
      this.value = theValue;
      this.next = null;
  }

  // post:  returns the integer value of this node
  public int getValue()
  {   return this.value;
  }

  // post:  returns the next node for this node
  public ElementNode getNext()
  {   return this.next;
  }

  // pre:  true
  // post:  sets the next node to be aNode
  public void setNext(ElementNode aNode)
  {   this.next =  aNode;
  }

  // pre: aValue is non-zero
  // post:  sets this node's integer value to aValue
  public void setValue(int aValue)
  {   this.value = aValue;
  }

  // post:  returns the column associated with this node
  public int getColumn()
  {   return this.col;
  }

  // post:  returns the row associated with this node
  public int getRow()
  {   return this.row;
  }

  // post:  returns a new ElementNode whose row and column are interchanged
  //        from this node's row and column (transposed values)
  public ElementNode transposeNode()
  {   ElementNode trans = new ElementNode(this.col, this.row, this.value);
      return trans;
  }


  public static void main(String[] args)
  {
      ElementNode e1 = new ElementNode(2,3,4);
      ElementNode e2 = new ElementNode(6,1,5);

      Test.ckEquals("Testing get value", 4, e1.getValue());
      Test.ckEquals("Testing getRow", 6, e2.getRow());
      Test.ckEquals("Testing getColumn", 3, e1.getColumn());

      e1.setNext(e2);
      Test.ckEquals("Testing getNext", e2.getValue(), e1.getNext().getValue());

      e1.setNext(null);
      Test.ckIsNull("Testing next is null", e1.getNext());

      e2.setValue(10);
      Test.ckEquals("Testing setValue", 10, e2.getValue());

      ElementNode trans = e1.transposeNode();
      Test.ckEquals("Testing transpose", 3, trans.getRow());
      Test.ckEquals("Testing transpose", 2, trans.getColumn());
      


      





  }


}


  
