cypher program help

  • (3 Pages)
  • +
  • 1
  • 2
  • 3

35 Replies - 2807 Views - Last Post: 01 April 2014 - 12:19 PM Rate Topic: ****- 2 Votes

#1 Preacher2012   User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 158
  • Joined: 02-November 12

cypher program help

Posted 29 March 2014 - 05:42 PM

SO I've taken intro to java 1 & 2 and now I'm taking data structures in java. My professor has talked about the LLNode, listInterface, RefUnsortedList, refSortedList, linked lists and etc. But we never learned to make something as complicated as a cypher class and such thing, and I'm confused on how to make a shallow copy of a list for one of the given classes. I'm going to post my lab assignment and would very much appreciate any and all help given to get me through this program.

Alright so this is what my professor wants us to do:

Cipher Class

Create a class for the cipher with the following methods:

default constructor: This constructor does nothing.
constructor with two parms (key and list of rotation counts): Each parm is a string; the key is a string of 26 lowercase letters and the rotation counts is a string of 26 digits. The key should be converted to an indexed list of Characters and the rotation counts should be converted to an indexed list of Integers.
encode: The encode method has one parm -- the plaintext string, and it returns the ciphertext string. Make a copy of the list that holds the key so that the original is not changed during encoding, because it will be needed for other calls to encode and decode. All non-letters, including blanks, should be left unchanged by the encode method. After you get your encode method working for lower case letters, make it work for uppercase letters too.
decode: The decode method has one parm -- the ciphertext string, and it returns the plaintext string. To decode, start with the original key and counts, and perform the same rotations as when encoding.

RefIndexedList

You will write a shcopy method for the RefIndexedList. The shcopy method has no parms and returns a RefIndexedList. The shcopy method will make a shallow copy of the list; this means that the method will create new LLNodes to point to the list elements, but it will not create copies of the list elements. Thus the original list and the clone will point to the same objects.

useCipher Class

Your main method should do the following:

read the key and rotation counts from a file; the first line should contain the key as a string of 26 lowercase letters and the second line should contain the rotation counts as a string of 26 digits
create a cipher using this key and rotation count
create a loop that prompts the user to enter a string (the plaintext); encode the plaintext and print the ciphertext, then decode the ciphertext and print the plaintext
keep prompting the user to enter a string until the user wants to exit

Here are the given classes:

RefUnsortedList:
//
//Lab 3

//----------------------------------------------------------------------------
// RefUnsortedList.java          by Dale/Joyce/Weems                 Chapter 6
//
// Implements the ListInterface using references (a linked list).
//
// Null elements are not permitted on a list.
//
// One constructor is provided, one that creates an empty list.
//----------------------------------------------------------------------------

public class RefUnsortedList<T> implements ListInterface<T> {

   protected int numElements;      // number of elements in this list
   protected LLNode<T> currentPos; // current position for iteration

   // set by find method
   protected boolean found;        // true if element found, else false
   protected LLNode<T> location;   // node containing element, if found
   protected LLNode<T> previous;   // node preceeding location

   protected LLNode<T> list;       // first node on the list

   public RefUnsortedList() {
      numElements = 0;
      list = null;
      currentPos = null;
   }

   public void add(T element) {
      // Adds element to this list.
      LLNode<T> newNode = new LLNode<T>(element);
      newNode.setLink(list);
      list = newNode;

      numElements++;
   }

   protected void find(T target) {
   // Searches list for an occurence of an element e such that
   // e.equals(target). If successful, sets instance variables
   // found to true, location to node containing e, and previous
   // to the node that links to location. If not successful, sets
   // found to false.
      location = list;
      found = false;

      while (location != null) {
         if (location.getInfo().equals(target)) { // if they match
            found = true;
            return;
         }
         else {
            previous = location;
            location = location.getLink();
         }
      }
   }

   public int size() {
   // Returns the number of elements on this list.
      return numElements;
   }

   public boolean contains (T element) {
   // Returns true if this list contains an element e such that
   // e.equals(element); otherwise, returns false.
      find(element);
      return found;
   }

   public boolean remove (T element) {
   // Removes an element e from this list such that e.equals(element)
   // and returns true; if no such element exists, returns false.
      find(element);
      if (found) {
         if (list == location)
            list = list.getLink();    // remove first node
         else
            previous.setLink(location.getLink());  // remove node at location

         numElements--;
      }
      return found;
   }

   public T get(T element) {
   // Returns an element e from this list such that e.equals(element);
   // if no such element exists, returns null.
      find(element);
      if (found)
         return location.getInfo();
      else
         return null;
   }

   public String toString() {
   // Returns a nicely formatted string that represents this list.
      LLNode<T> currNode = list;
      String listString = "List:\n";
      while (currNode != null) {
         listString = listString + "  " + currNode.getInfo() + "\n";
         currNode = currNode.getLink();
      }
      return listString;
   }

   public void reset() {
   // Initializes current position for an iteration through this list,
   // to the first element on this list.
      currentPos  = list;
   }

   public T getNext() {
   // Preconditions: The list is not empty
   //                The list has been reset
   //                The list has not been modified since most recent reset
   //
   // Returns the element at the current position on this list.
   // If the current position is the last element, then it advances the value
   // of the current position to the first element; otherwise, it advances
   // the value of the current position to the next element.
      T next = currentPos.getInfo();
      if (currentPos.getLink() == null)
         currentPos = list;
      else
         currentPos = currentPos.getLink();
      return next;
   }


}



RefIndexedList:
//
//Lab 3

//-------------------------------------------------------------------------
// RefIndexedList.java
//
// Implements the IndexedListInterface using a linked list
//
// Null elements are not permitted on a list.
//
//----------------------------------------------------------------------------


public class RefIndexedList<T> extends RefUnsortedList<T>
                                 implements IndexedListInterface<T> {

   public RefIndexedList() {
      super();
   }

   public void add(int index, T element) {
   // Throws IndexOutOfBoundsException if passed an index argument
   // such that index < 0 or index > size().
   // Otherwise, adds element to this list at position index; all current
   // elements at that index or higher have 1 added to their index.

      if ((index < 0) || (index > size()))
         throw new IndexOutOfBoundsException("illegal index of " + index +
                                " passed to RefIndexedList add method.\n");
      LLNode<T> newnode = new LLNode<T>(element);
      find(index);
      if (location == list) {
		  // add to beginning of list: change list
		  newnode.setLink(location);
		  list = newnode;
	  }
	  else {
		  //add somewhere else: change link of previous node
		  newnode.setLink(location);
		  previous.setLink(newnode);
	  }
	  numElements++;
   }

   public T set(int index, T element) {
   // Throws IndexOutOfBoundsException if passed an index argument
   // such that index < 0 or index >= size().
   // Otherwise, replaces element on this list at position index and
   // returns the replaced element.
      if ((index < 0) || (index >= size()))
         throw new IndexOutOfBoundsException("illegal index of " + index +
                                " passed to ArrayIndexedList set method.\n");

      find(index);
      T hold = location.getInfo();
      location.setInfo(element);
      return hold;
   }

   public T get(int index) {
   // Throws IndexOutOfBoundsException if passed an index argument
   // such that index < 0 or index >= size().
   // Otherwise, returns the element on this list at position index.
      if ((index < 0) || (index >= size()))
         throw new IndexOutOfBoundsException("illegal index of " + index +
                               " passed to ArrayIndexedList set method.\n");

      find(index);
      return location.getInfo();
   }

   public int indexOf(T element) {
   // If this list contains an element e such that e.equals(element),
   // then returns the index of the first such element.
   // Otherwise, returns -1.
      int count = 0;
      location = list;

      while (location != null) {
         if (location.getInfo().equals(element)) { // if they match
            return count;
         }
         else {
            previous = location;
            location = location.getLink();
            count++;
         }
      }
      return -1;
   }

   public T remove(int index) {
   // Throws IndexOutOfBoundsException if passed an index argument
   // such that index < 0 or index >= size().
   // Otherwise, removes element on this list at position index and
   // returns the removed element; all current elements at positions
   // higher than that index have 1 subtracted from their index.
      if ((index < 0) || (index >= size()))
         throw new IndexOutOfBoundsException("illegal index of " + index +
                                " passed to ArrayIndexedList remove method.\n");

      find(index);
      T hold = location.getInfo();
      if (location == list) {
         // remove first item: change list
         list = location.getLink();
	  }
	  else {
	     previous.setLink(location.getLink());
	  }
      numElements--;
      return hold;
   }

   protected void find(int index) {
   // Searches list for the element in location index. If successful,
   // it sets instance variables found to true, location to node
   // containing e, and previous to the node that links to location.
   // If not successful, sets found to false.
      location = list;
      found = false;
      int count = 0;

      while (location != null) {
         if (count == index) { // if they match
            found = true;
            return;
         }
         else {
            previous = location;
            location = location.getLink();
            count++;
         }
      }
   }
}



LLNode:
//
//Lab 3

//----------------------------------------------------------------------------
// LLNode.java            by Dale/Joyce/Weems                  Chapter 3
//
// Implements <T> nodes for a Linked List.
//----------------------------------------------------------------------------

//package support;

public class LLNode<T>
{
  private LLNode<T> link;
  private T info;

  public LLNode(T info)
  {
    this.info = info;
    link = null;
  }

  public void setInfo(T info)
  // Sets info of this LLNode.
  {
    this.info = info;
  }

  public T getInfo()
  // Returns info of this LLONode.
  {
    return info;
  }

  public void setLink(LLNode<T> link)
  // Sets link of this LLNode.
  {
    this.link = link;
  }

  public LLNode<T> getLink()
  // Returns link of this LLNode.
  {
    return link;
  }
}




ListInterface:
//
//Lab 3

//----------------------------------------------------------------------------
// ListInterface.java            by Dale/Joyce/Weems                 Chapter 6
//
// The lists are unbounded and allow duplicate elements, but do not allow
// null elements. As a general precondition, null elements are not passed as
// arguments to any of the methods.
//
// The list has a special property called the current position - the position
// of the next element to be accessed by getNext during an iteration through
// the list. Only reset and getNext affect the current position.
//----------------------------------------------------------------------------

//package ch06.lists;

public interface ListInterface<T>
{
  int size();
  // Returns the number of elements on this list.

  void add(T element);
  // Adds element to this list.

  boolean remove (T element);
  // Removes an element e from this list such that e.equals(element)
  // and returns true; if no such element exists, returns false.

  boolean contains (T element);
  // Returns true if this list contains an element e such that
  // e.equals(element); otherwise, returns false.

  T get(T element);
  // Returns an element e from this list such that e.equals(element);
  // if no such element exists, returns null.

  String toString();
  // Returns a nicely formatted string that represents this list.

  void reset();
  // Initializes current position for an iteration through this list,
  // to the first element on this list.

  T getNext();
  // Preconditions: The list is not empty
  //                The list has been reset
  //                The list has not been modified since the most recent reset
  //
  // Returns the element at the current position on this list.
  // If the current position is the last element, then it advances the value
  // of the current position to the first element; otherwise, it advances
  // the value of the current position to the next element.
}



IndexedListInterface:
//
//Lab 3

//----------------------------------------------------------------------
// IndexedListInterface.java    by Dale/Joyce/Weems            Chapter 6
//
// Extends the ListInterface with methods specific to indexed lists.
//----------------------------------------------------------------------

//package ch06.lists;

public interface IndexedListInterface<T> extends ListInterface<T>
{
  void add(int index, T element);
  // Throws IndexOutOfBoundsException if passed an index argument
  // such that index < 0 or index > size().
  // Otherwise, adds element to this list at position index; all current
  // elements at that position or higher have 1 added to their index.

  T set(int index, T element);
  // Throws IndexOutOfBoundsException if passed an index argument
  // such that index < 0 or index >= size().
  // Otherwise, replaces element on this list at position index and
  // returns the replaced element.

  T get(int index);
  // Throws IndexOutOfBoundsException if passed an index argument
  // such that index < 0 or index >= size().
  // Otherwise, returns the element on this list at position index.

  int indexOf(T element);
  // If this list contains an element e such that e.equals(element),
  // then returns the index of the first such element.
  // Otherwise, returns -1.

  T remove(int index);
  // Throws IndexOutOfBoundsException if passed an index argument
  // such that index < 0 or index >= size().
  // Otherwise, removes element on this list at position index and
  // returns the removed element; all current elements at positions
  // higher than that position have 1 subtracted from their index.
}



Ok so first thing is first, making a shallow copy of the list in RefIndexedList with a shcopy maethod.The shcopy method has no parms and returns a RefIndexedList. The shcopy method will make a shallow copy of the list; this means that the method will create new LLNodes to point to the list elements, but it will not create copies of the list elements. Thus the original list and the clone will point to the same objects. so I'm confused about how to go on making this method, here is my attempted method with the whole RefIndexedList class:
//Kevin Patel
//Lab 3: Crytography

//-------------------------------------------------------------------------
// RefIndexedList.java
//
// Implements the IndexedListInterface using a linked list
//
// Null elements are not permitted on a list.
//
//----------------------------------------------------------------------------


public class RefIndexedList<T> extends RefUnsortedList<T>
                                 implements IndexedListInterface<T> {

   public RefIndexedList() {
      super();
   }

   public void add(int index, T element) {
   // Throws IndexOutOfBoundsException if passed an index argument
   // such that index < 0 or index > size().
   // Otherwise, adds element to this list at position index; all current
   // elements at that index or higher have 1 added to their index.

      if ((index < 0) || (index > size()))
         throw new IndexOutOfBoundsException("illegal index of " + index +
                                " passed to RefIndexedList add method.\n");
      LLNode<T> newnode = new LLNode<T>(element);
      find(index);
      if (location == list) {
		  // add to beginning of list: change list
		  newnode.setLink(location);
		  list = newnode;
	  }
	  else {
		  //add somewhere else: change link of previous node
		  newnode.setLink(location);
		  previous.setLink(newnode);
	  }
	  numElements++;
   }

   public T set(int index, T element) {
   // Throws IndexOutOfBoundsException if passed an index argument
   // such that index < 0 or index >= size().
   // Otherwise, replaces element on this list at position index and
   // returns the replaced element.
      if ((index < 0) || (index >= size()))
         throw new IndexOutOfBoundsException("illegal index of " + index +
                                " passed to ArrayIndexedList set method.\n");

      find(index);
      T hold = location.getInfo();
      location.setInfo(element);
      return hold;
   }

   public T get(int index) {
   // Throws IndexOutOfBoundsException if passed an index argument
   // such that index < 0 or index >= size().
   // Otherwise, returns the element on this list at position index.
      if ((index < 0) || (index >= size()))
         throw new IndexOutOfBoundsException("illegal index of " + index +
                               " passed to ArrayIndexedList set method.\n");

      find(index);
      return location.getInfo();
   }

   public int indexOf(T element) {
   // If this list contains an element e such that e.equals(element),
   // then returns the index of the first such element.
   // Otherwise, returns -1.
      int count = 0;
      location = list;

      while (location != null) {
         if (location.getInfo().equals(element)) { // if they match
            return count;
         }
         else {
            previous = location;
            location = location.getLink();
            count++;
         }
      }
      return -1;
   }

   public T remove(int index) {
   // Throws IndexOutOfBoundsException if passed an index argument
   // such that index < 0 or index >= size().
   // Otherwise, removes element on this list at position index and
   // returns the removed element; all current elements at positions
   // higher than that index have 1 subtracted from their index.
      if ((index < 0) || (index >= size()))
         throw new IndexOutOfBoundsException("illegal index of " + index +
                                " passed to ArrayIndexedList remove method.\n");

      find(index);
      T hold = location.getInfo();
      if (location == list) {
         // remove first item: change list
         list = location.getLink();
	  }
	  else {
	     previous.setLink(location.getLink());
	  }
      numElements--;
      return hold;
   }

   protected void find(int index) {
   // Searches list for the element in location index. If successful,
   // it sets instance variables found to true, location to node
   // containing e, and previous to the node that links to location.
   // If not successful, sets found to false.
      location = list;
      found = false;
      int count = 0;

      while (location != null) {
         if (count == index) { // if they match
            found = true;
            return;
         }
         else {
            previous = location;
            location = location.getLink();
            count++;
         }
      }
   }

   public T shcopy()//creates shallow copy of the list, new nodes to point to list elements, but not
   //create copies of the list elements, so original list and new list will point to the same objects
   {
	   LLNode<T> list = new LLNode<T>();
	   LLNode<T> newNode = new LLNode<T>
	   list = newNode;
   }
}



I get the errors:
F:\CSC236Java\KevinPatelLab3\RefIndexedList.java:141: error: '(' or '[' expected
list = newNode;
^
F:\CSC236Java\KevinPatelLab3\RefIndexedList.java:141: error: illegal start of expression
list = newNode;
^
2 errors

Tool completed with exit code 1

I apologize for such a long post, especially to those on their phones and tablets, but I wanted to give as many details as possible to give a proper understanding of the assignment. So thank you for bearing with me, any help is appreciated.

Is This A Good Question/Topic? 0
  • +

Replies To: cypher program help

#2 andrewsw   User is offline

  • head thrashing
  • member icon

Reputation: 6627
  • View blog
  • Posts: 27,088
  • Joined: 12-December 12

Re: cypher program help

Posted 29 March 2014 - 05:51 PM

I haven't read your topic, just noticed this at the bottom:

Quote

F:\CSC236Java\KevinPatelLab3\RefIndexedList.java:141: error: '(' or '[' expected
list = newNode;
^

So which is this line in your posted code? This should be just a simple syntax error to correct.

Once you've fixed this I think you should re-state your question, not everyone will be keen to read through your long topic before discovering what the question is.

This post has been edited by andrewsw: 29 March 2014 - 05:52 PM

Was This Post Helpful? 0
  • +
  • -

#3 Preacher2012   User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 158
  • Joined: 02-November 12

Re: cypher program help

Posted 29 March 2014 - 05:53 PM

this is the line the error is pointed to:
public T shcopy()//creates shallow copy of the list, new nodes to point to list elements, but not
   //create copies of the list elements, so original list and new list will point to the same objects
   {
	   LLNode<T> list = new LLNode<T>();
	   LLNode<T> newNode = new LLNode<T>
	   list = newNode; //this line
   }


Was This Post Helpful? 0
  • +
  • -

#4 andrewsw   User is offline

  • head thrashing
  • member icon

Reputation: 6627
  • View blog
  • Posts: 27,088
  • Joined: 12-December 12

Re: cypher program help

Posted 29 March 2014 - 05:57 PM

The error originates on the previous line. Compare line 4 (that works) to line 5 (that doesn't).
Was This Post Helpful? 0
  • +
  • -

#5 Preacher2012   User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 158
  • Joined: 02-November 12

Re: cypher program help

Posted 29 March 2014 - 06:10 PM

ok I'll post the stuff as needed.

RefUnsortedList:
//
//Lab 3

//----------------------------------------------------------------------------
// RefUnsortedList.java          by Dale/Joyce/Weems                 Chapter 6
//
// Implements the ListInterface using references (a linked list).
//
// Null elements are not permitted on a list.
//
// One constructor is provided, one that creates an empty list.
//----------------------------------------------------------------------------

public class RefUnsortedList<T> implements ListInterface<T> {

   protected int numElements;      // number of elements in this list
   protected LLNode<T> currentPos; // current position for iteration

   // set by find method
   protected boolean found;        // true if element found, else false
   protected LLNode<T> location;   // node containing element, if found
   protected LLNode<T> previous;   // node preceeding location

   protected LLNode<T> list;       // first node on the list

   public RefUnsortedList() {
      numElements = 0;
      list = null;
      currentPos = null;
   }

   public void add(T element) {
      // Adds element to this list.
      LLNode<T> newNode = new LLNode<T>(element);
      newNode.setLink(list);
      list = newNode;

      numElements++;
   }

   protected void find(T target) {
   // Searches list for an occurence of an element e such that
   // e.equals(target). If successful, sets instance variables
   // found to true, location to node containing e, and previous
   // to the node that links to location. If not successful, sets
   // found to false.
      location = list;
      found = false;

      while (location != null) {
         if (location.getInfo().equals(target)) { // if they match
            found = true;
            return;
         }
         else {
            previous = location;
            location = location.getLink();
         }
      }
   }

   public int size() {
   // Returns the number of elements on this list.
      return numElements;
   }

   public boolean contains (T element) {
   // Returns true if this list contains an element e such that
   // e.equals(element); otherwise, returns false.
      find(element);
      return found;
   }

   public boolean remove (T element) {
   // Removes an element e from this list such that e.equals(element)
   // and returns true; if no such element exists, returns false.
      find(element);
      if (found) {
         if (list == location)
            list = list.getLink();    // remove first node
         else
            previous.setLink(location.getLink());  // remove node at location

         numElements--;
      }
      return found;
   }

   public T get(T element) {
   // Returns an element e from this list such that e.equals(element);
   // if no such element exists, returns null.
      find(element);
      if (found)
         return location.getInfo();
      else
         return null;
   }

   public String toString() {
   // Returns a nicely formatted string that represents this list.
      LLNode<T> currNode = list;
      String listString = "List:\n";
      while (currNode != null) {
         listString = listString + "  " + currNode.getInfo() + "\n";
         currNode = currNode.getLink();
      }
      return listString;
   }

   public void reset() {
   // Initializes current position for an iteration through this list,
   // to the first element on this list.
      currentPos  = list;
   }

   public T getNext() {
   // Preconditions: The list is not empty
   //                The list has been reset
   //                The list has not been modified since most recent reset
   //
   // Returns the element at the current position on this list.
   // If the current position is the last element, then it advances the value
   // of the current position to the first element; otherwise, it advances
   // the value of the current position to the next element.
      T next = currentPos.getInfo();
      if (currentPos.getLink() == null)
         currentPos = list;
      else
         currentPos = currentPos.getLink();
      return next;
   }


}



I am to create a shcopy method in the RefIndexedList below:
//Kevin Patel
//Lab 3: Crytography

//-------------------------------------------------------------------------
// RefIndexedList.java
//
// Implements the IndexedListInterface using a linked list
//
// Null elements are not permitted on a list.
//
//----------------------------------------------------------------------------


public class RefIndexedList<T> extends RefUnsortedList<T>
                                 implements IndexedListInterface<T> {

   public RefIndexedList() {
      super();
   }

   public void add(int index, T element) {
   // Throws IndexOutOfBoundsException if passed an index argument
   // such that index < 0 or index > size().
   // Otherwise, adds element to this list at position index; all current
   // elements at that index or higher have 1 added to their index.

      if ((index < 0) || (index > size()))
         throw new IndexOutOfBoundsException("illegal index of " + index +
                                " passed to RefIndexedList add method.\n");
      LLNode<T> newnode = new LLNode<T>(element);
      find(index);
      if (location == list) {
		  // add to beginning of list: change list
		  newnode.setLink(location);
		  list = newnode;
	  }
	  else {
		  //add somewhere else: change link of previous node
		  newnode.setLink(location);
		  previous.setLink(newnode);
	  }
	  numElements++;
   }

   public T set(int index, T element) {
   // Throws IndexOutOfBoundsException if passed an index argument
   // such that index < 0 or index >= size().
   // Otherwise, replaces element on this list at position index and
   // returns the replaced element.
      if ((index < 0) || (index >= size()))
         throw new IndexOutOfBoundsException("illegal index of " + index +
                                " passed to ArrayIndexedList set method.\n");

      find(index);
      T hold = location.getInfo();
      location.setInfo(element);
      return hold;
   }

   public T get(int index) {
   // Throws IndexOutOfBoundsException if passed an index argument
   // such that index < 0 or index >= size().
   // Otherwise, returns the element on this list at position index.
      if ((index < 0) || (index >= size()))
         throw new IndexOutOfBoundsException("illegal index of " + index +
                               " passed to ArrayIndexedList set method.\n");

      find(index);
      return location.getInfo();
   }

   public int indexOf(T element) {
   // If this list contains an element e such that e.equals(element),
   // then returns the index of the first such element.
   // Otherwise, returns -1.
      int count = 0;
      location = list;

      while (location != null) {
         if (location.getInfo().equals(element)) { // if they match
            return count;
         }
         else {
            previous = location;
            location = location.getLink();
            count++;
         }
      }
      return -1;
   }

   public T remove(int index) {
   // Throws IndexOutOfBoundsException if passed an index argument
   // such that index < 0 or index >= size().
   // Otherwise, removes element on this list at position index and
   // returns the removed element; all current elements at positions
   // higher than that index have 1 subtracted from their index.
      if ((index < 0) || (index >= size()))
         throw new IndexOutOfBoundsException("illegal index of " + index +
                                " passed to ArrayIndexedList remove method.\n");

      find(index);
      T hold = location.getInfo();
      if (location == list) {
         // remove first item: change list
         list = location.getLink();
	  }
	  else {
	     previous.setLink(location.getLink());
	  }
      numElements--;
      return hold;
   }

   protected void find(int index) {
   // Searches list for the element in location index. If successful,
   // it sets instance variables found to true, location to node
   // containing e, and previous to the node that links to location.
   // If not successful, sets found to false.
      location = list;
      found = false;
      int count = 0;

      while (location != null) {
         if (count == index) { // if they match
            found = true;
            return;
         }
         else {
            previous = location;
            location = location.getLink();
            count++;
         }
      }
   }

   public T shcopy()//creates shallow copy of the list, new nodes to point to list elements, but not
   //create copies of the list elements, so original list and new list will point to the same objects
   //Should then return the new RefIndexedList
   {
	   LLNode<T> list = new LLNode<T>();
	   LLNode<T> newNode = new LLnNode<T>();
	   list = newNode;
   }
}



so im supposed to create a shallow copy of the list in RefUnsortedList, new nodes to point to list elements, but not create copies of the list elements
so both lists will point to the same objects.

new errors after a revision seen above:
F:\CSC236Java\KevinPatelLab3\RefIndexedList.java:141: error: constructor LLNode in class LLNode<T#2> cannot be applied to given types;
LLNode<T> list = new LLNode<T>();
^
required: T#1
found: no arguments
reason: actual and formal argument lists differ in length
where T#1,T#2 are type-variables:
T#1 extends Object declared in class RefIndexedList
T#2 extends Object declared in class LLNode
F:\CSC236Java\KevinPatelLab3\RefIndexedList.java:142: error: cannot find symbol
LLNode<T> newNode = new LLnNode<T>();
^
symbol: class LLnNode
location: class RefIndexedList<T>
where T is a type-variable:
T extends Object declared in class RefIndexedList
2 errors

Tool completed with exit code 1
Was This Post Helpful? 0
  • +
  • -

#6 Preacher2012   User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 158
  • Joined: 02-November 12

Re: cypher program help

Posted 29 March 2014 - 06:34 PM

How do I fix my shcopy method to get it to work properly?

heres the list creation in RefUnsortedList:
protected int numElements;      // number of elements in this list
   protected LLNode<T> currentPos; // current position for iteration

   // set by find method
   protected boolean found;        // true if element found, else false
   protected LLNode<T> location;   // node containing element, if found
   protected LLNode<T> previous;   // node preceeding location

   protected LLNode<T> list;       // first node on the list

   public RefUnsortedList() {
      numElements = 0;
      list = null;
      currentPos = null;
   }

   public void add(T element) {
      // Adds element to this list.
      LLNode<T> newNode = new LLNode<T>(element);
      newNode.setLink(list);
      list = newNode;

      numElements++;
   }



heres my method in RefIndexedList:
public T shcopy()//creates shallow copy of the list, new nodes to point to list elements, but not
   //create copies of the list elements, so original list and new list will point to the same objects
   //Should then return the new RefIndexedList
   {
	   LLNode<T> list = new LLNode<T>();
	   LLNode<T> newNode = new LLnNode<T>();
	   list = newNode;
   }



heres the error again:

F:\CSC236Java\KevinPatelLab3\RefIndexedList.java:141: error: constructor LLNode in class LLNode<T#2> cannot be applied to given types;
LLNode<T> list = new LLNode<T>();
^
required: T#1
found: no arguments
reason: actual and formal argument lists differ in length
where T#1,T#2 are type-variables:
T#1 extends Object declared in class RefIndexedList
T#2 extends Object declared in class LLNode
F:\CSC236Java\KevinPatelLab3\RefIndexedList.java:142: error: cannot find symbol
LLNode<T> newNode = new LLnNode<T>();
^
symbol: class LLnNode
location: class RefIndexedList<T>
where T is a type-variable:
T extends Object declared in class RefIndexedList
2 errors

Tool completed with exit code 1

how can i fix this?

This post has been edited by Preacher2012: 29 March 2014 - 06:35 PM

Was This Post Helpful? 0
  • +
  • -

#7 andrewsw   User is offline

  • head thrashing
  • member icon

Reputation: 6627
  • View blog
  • Posts: 27,088
  • Joined: 12-December 12

Re: cypher program help

Posted 29 March 2014 - 07:21 PM

In response to your PM, your question has not been posted for that long so you may still get some responses.

As I mentioned, your original, and subsequent posts, are very long. It is not easy to discover what you are actually asking.

But your code has errors, so it remains unclear whether you want help to fix these errors or just more general advice. Fixing coding-errors should nearly always take priority (unless you plan to abandon the code); in which case, you might have delayed a more general question until these errors were fixed.

At the moment though..

Quote

how can i fix this?

What do you think the error message(s) mean? Have you searched the errors?

Added: And an hour is a very short time period for a volunteer, community, forum.. especially given the Western time.
Was This Post Helpful? 0
  • +
  • -

#8 Preacher2012   User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 158
  • Joined: 02-November 12

Re: cypher program help

Posted 29 March 2014 - 07:46 PM

I'd like help fixing the errors in my code. this method specifically:
public T shcopy()//creates shallow copy of the list, new nodes to point to list elements, but not
   //create copies of the list elements, so original list and new list will point to the same objects
   //Should then return the new RefIndexedList
   {
	   LLNode<T> list = new LLNode<T>();
	   LLNode<T> newNode = new LLnNode<T>();
	   list = newNode;
   }



I am trying to make a shallow copy of a list as mentioned in the method's comment. so what is the proper way to make a shallow copy of the list made in the following class?
public class RefUnsortedList<T> implements ListInterface<T> {

   protected int numElements;      // number of elements in this list
   protected LLNode<T> currentPos; // current position for iteration

   // set by find method
   protected boolean found;        // true if element found, else false
   protected LLNode<T> location;   // node containing element, if found
   protected LLNode<T> previous;   // node preceeding location

   protected LLNode<T> list;       // first node on the list

   public RefUnsortedList() {
      numElements = 0;
      list = null;
      currentPos = null;
   }

   public void add(T element) {
      // Adds element to this list.
      LLNode<T> newNode = new LLNode<T>(element);
      newNode.setLink(list);
      list = newNode;

      numElements++;
   }

   protected void find(T target) {
   // Searches list for an occurence of an element e such that
   // e.equals(target). If successful, sets instance variables
   // found to true, location to node containing e, and previous
   // to the node that links to location. If not successful, sets
   // found to false.
      location = list;
      found = false;

      while (location != null) {
         if (location.getInfo().equals(target)) { // if they match
            found = true;
            return;
         }
         else {
            previous = location;
            location = location.getLink();
         }
      }
   }

   public int size() {
   // Returns the number of elements on this list.
      return numElements;
   }

   public boolean contains (T element) {
   // Returns true if this list contains an element e such that
   // e.equals(element); otherwise, returns false.
      find(element);
      return found;
   }

   public boolean remove (T element) {
   // Removes an element e from this list such that e.equals(element)
   // and returns true; if no such element exists, returns false.
      find(element);
      if (found) {
         if (list == location)
            list = list.getLink();    // remove first node
         else
            previous.setLink(location.getLink());  // remove node at location

         numElements--;
      }
      return found;
   }

   public T get(T element) {
   // Returns an element e from this list such that e.equals(element);
   // if no such element exists, returns null.
      find(element);
      if (found)
         return location.getInfo();
      else
         return null;
   }

   public String toString() {
   // Returns a nicely formatted string that represents this list.
      LLNode<T> currNode = list;
      String listString = "List:\n";
      while (currNode != null) {
         listString = listString + "  " + currNode.getInfo() + "\n";
         currNode = currNode.getLink();
      }
      return listString;
   }

   public void reset() {
   // Initializes current position for an iteration through this list,
   // to the first element on this list.
      currentPos  = list;
   }

   public T getNext() {
   // Preconditions: The list is not empty
   //                The list has been reset
   //                The list has not been modified since most recent reset
   //
   // Returns the element at the current position on this list.
   // If the current position is the last element, then it advances the value
   // of the current position to the first element; otherwise, it advances
   // the value of the current position to the next element.
      T next = currentPos.getInfo();
      if (currentPos.getLink() == null)
         currentPos = list;
      else
         currentPos = currentPos.getLink();
      return next;
   }


}


Was This Post Helpful? 0
  • +
  • -

#9 andrewsw   User is offline

  • head thrashing
  • member icon

Reputation: 6627
  • View blog
  • Posts: 27,088
  • Joined: 12-December 12

Re: cypher program help

Posted 29 March 2014 - 07:53 PM

You have a spelling error with LLnNode which explains the second error.
Was This Post Helpful? 0
  • +
  • -

#10 Preacher2012   User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 158
  • Joined: 02-November 12

Re: cypher program help

Posted 29 March 2014 - 08:09 PM

oh yea that was a silly mistake. Here's the method now:
public T shcopy()//creates shallow copy of the list, new nodes to point to list elements, but not
   //create copies of the list elements, so original list and new list will point to the same objects
   //Should then return the new RefIndexedList
   {
	   LLNode<T> list = new LLNode<T>();
	   LLNode<T> newNode = new LLNode<T>();
	   list = newNode;
   }



how can I fix this method to fix these errors:

F:\CSC236Java\KevinPatelLab3\RefIndexedList.java:141: error: constructor LLNode in class LLNode<T#2> cannot be applied to given types;
LLNode<T> list = new LLNode<T>();
^
required: T#1
found: no arguments
reason: actual and formal argument lists differ in length
where T#1,T#2 are type-variables:
T#1 extends Object declared in class RefIndexedList
T#2 extends Object declared in class LLNode
F:\CSC236Java\KevinPatelLab3\RefIndexedList.java:142: error: constructor LLNode in class LLNode<T#2> cannot be applied to given types;
LLNode<T> newNode = new LLNode<T>();
^
required: T#1
found: no arguments
reason: actual and formal argument lists differ in length
where T#1,T#2 are type-variables:
T#1 extends Object declared in class RefIndexedList
T#2 extends Object declared in class LLNode
2 errors

Tool completed with exit code 1
Was This Post Helpful? 0
  • +
  • -

#11 andrewsw   User is offline

  • head thrashing
  • member icon

Reputation: 6627
  • View blog
  • Posts: 27,088
  • Joined: 12-December 12

Re: cypher program help

Posted 29 March 2014 - 08:25 PM

I'll take a guess that you need to supply the argument X in here:
LLNode<T> list = new LLNode<T>(X);

because there is no empty (nullary) constructor for LLNode. X needs to be an object of type T, whatever that is.

Or supply the empty, default, constructor for LLNode. But that code is supplied to you I believe, so I doubt that you should do this.

It's no longer my area though, so good luck!
Was This Post Helpful? 0
  • +
  • -

#12 Preacher2012   User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 158
  • Joined: 02-November 12

Re: cypher program help

Posted 30 March 2014 - 04:06 PM

OK I tried getting help yesterday but no luck, I'm gonna try again. I am doing a lab where I have to make a cipher program using some given classes. This lab involves the list interface and LLNodes and things of that sort. Yesterday someone tried to help but ended up saying that his is no longer their "Area" (so why try waste time? I dont know but thanks for trying). I am not trying to get complete solutions because that would be cheating this is due tomorrow so I'd like help from only those who can actually help. I apologize if it seems like I'm ranting. Now I'll be very specific on exactly that I'm supposed to do and what problems I'm encountering that I need help resolving. Lets begin by listing all the classes so we have an understanding of the lab:

ListInterface:
//
//Lab 3

//----------------------------------------------------------------------------
// ListInterface.java            by Dale/Joyce/Weems                 Chapter 6
//
// The lists are unbounded and allow duplicate elements, but do not allow
// null elements. As a general precondition, null elements are not passed as
// arguments to any of the methods.
//
// The list has a special property called the current position - the position
// of the next element to be accessed by getNext during an iteration through
// the list. Only reset and getNext affect the current position.
//----------------------------------------------------------------------------

//package ch06.lists;

public interface ListInterface<T>
{
  int size();
  // Returns the number of elements on this list.

  void add(T element);
  // Adds element to this list.

  boolean remove (T element);
  // Removes an element e from this list such that e.equals(element)
  // and returns true; if no such element exists, returns false.

  boolean contains (T element);
  // Returns true if this list contains an element e such that
  // e.equals(element); otherwise, returns false.

  T get(T element);
  // Returns an element e from this list such that e.equals(element);
  // if no such element exists, returns null.

  String toString();
  // Returns a nicely formatted string that represents this list.

  void reset();
  // Initializes current position for an iteration through this list,
  // to the first element on this list.

  T getNext();
  // Preconditions: The list is not empty
  //                The list has been reset
  //                The list has not been modified since the most recent reset
  //
  // Returns the element at the current position on this list.
  // If the current position is the last element, then it advances the value
  // of the current position to the first element; otherwise, it advances
  // the value of the current position to the next element.
}



IndexedListInterface:
//
//Lab 3

//----------------------------------------------------------------------
// IndexedListInterface.java    by Dale/Joyce/Weems            Chapter 6
//
// Extends the ListInterface with methods specific to indexed lists.
//----------------------------------------------------------------------

//package ch06.lists;

public interface IndexedListInterface<T> extends ListInterface<T>
{
  void add(int index, T element);
  // Throws IndexOutOfBoundsException if passed an index argument
  // such that index < 0 or index > size().
  // Otherwise, adds element to this list at position index; all current
  // elements at that position or higher have 1 added to their index.

  T set(int index, T element);
  // Throws IndexOutOfBoundsException if passed an index argument
  // such that index < 0 or index >= size().
  // Otherwise, replaces element on this list at position index and
  // returns the replaced element.

  T get(int index);
  // Throws IndexOutOfBoundsException if passed an index argument
  // such that index < 0 or index >= size().
  // Otherwise, returns the element on this list at position index.

  int indexOf(T element);
  // If this list contains an element e such that e.equals(element),
  // then returns the index of the first such element.
  // Otherwise, returns -1.

  T remove(int index);
  // Throws IndexOutOfBoundsException if passed an index argument
  // such that index < 0 or index >= size().
  // Otherwise, removes element on this list at position index and
  // returns the removed element; all current elements at positions
  // higher than that position have 1 subtracted from their index.
}



LLNode:
//
//Lab 3

//----------------------------------------------------------------------------
// LLNode.java            by Dale/Joyce/Weems                  Chapter 3
//
// Implements <T> nodes for a Linked List.
//----------------------------------------------------------------------------

//package support;

public class LLNode<T>
{
  private LLNode<T> link;
  private T info;

  public LLNode(T info)
  {
    this.info = info;
    link = null;
  }

  public void setInfo(T info)
  // Sets info of this LLNode.
  {
    this.info = info;
  }

  public T getInfo()
  // Returns info of this LLONode.
  {
    return info;
  }

  public void setLink(LLNode<T> link)
  // Sets link of this LLNode.
  {
    this.link = link;
  }

  public LLNode<T> getLink()
  // Returns link of this LLNode.
  {
    return link;
  }
}



RefUnsortedList:
//
//Lab 3

//----------------------------------------------------------------------------
// RefUnsortedList.java          by Dale/Joyce/Weems                 Chapter 6
//
// Implements the ListInterface using references (a linked list).
//
// Null elements are not permitted on a list.
//
// One constructor is provided, one that creates an empty list.
//----------------------------------------------------------------------------

public class RefUnsortedList<T> implements ListInterface<T> {

   protected int numElements;      // number of elements in this list
   protected LLNode<T> currentPos; // current position for iteration

   // set by find method
   protected boolean found;        // true if element found, else false
   protected LLNode<T> location;   // node containing element, if found
   protected LLNode<T> previous;   // node preceeding location

   protected LLNode<T> list;       // first node on the list

   public RefUnsortedList() {
      numElements = 0;
      list = null;
      currentPos = null;
   }

   public void add(T element) {
      // Adds element to this list.
      LLNode<T> newNode = new LLNode<T>(element);
      newNode.setLink(list);
      list = newNode;

      numElements++;
   }

   protected void find(T target) {
   // Searches list for an occurence of an element e such that
   // e.equals(target). If successful, sets instance variables
   // found to true, location to node containing e, and previous
   // to the node that links to location. If not successful, sets
   // found to false.
      location = list;
      found = false;

      while (location != null) {
         if (location.getInfo().equals(target)) { // if they match
            found = true;
            return;
         }
         else {
            previous = location;
            location = location.getLink();
         }
      }
   }

   public int size() {
   // Returns the number of elements on this list.
      return numElements;
   }

   public boolean contains (T element) {
   // Returns true if this list contains an element e such that
   // e.equals(element); otherwise, returns false.
      find(element);
      return found;
   }

   public boolean remove (T element) {
   // Removes an element e from this list such that e.equals(element)
   // and returns true; if no such element exists, returns false.
      find(element);
      if (found) {
         if (list == location)
            list = list.getLink();    // remove first node
         else
            previous.setLink(location.getLink());  // remove node at location

         numElements--;
      }
      return found;
   }

   public T get(T element) {
   // Returns an element e from this list such that e.equals(element);
   // if no such element exists, returns null.
      find(element);
      if (found)
         return location.getInfo();
      else
         return null;
   }

   public String toString() {
   // Returns a nicely formatted string that represents this list.
      LLNode<T> currNode = list;
      String listString = "List:\n";
      while (currNode != null) {
         listString = listString + "  " + currNode.getInfo() + "\n";
         currNode = currNode.getLink();
      }
      return listString;
   }

   public void reset() {
   // Initializes current position for an iteration through this list,
   // to the first element on this list.
      currentPos  = list;
   }

   public T getNext() {
   // Preconditions: The list is not empty
   //                The list has been reset
   //                The list has not been modified since most recent reset
   //
   // Returns the element at the current position on this list.
   // If the current position is the last element, then it advances the value
   // of the current position to the first element; otherwise, it advances
   // the value of the current position to the next element.
      T next = currentPos.getInfo();
      if (currentPos.getLink() == null)
         currentPos = list;
      else
         currentPos = currentPos.getLink();
      return next;
   }


}



RefIndexedList:
//Kevin Patel
//Lab 3: Crytography

//-------------------------------------------------------------------------
// RefIndexedList.java
//
// Implements the IndexedListInterface using a linked list
//
// Null elements are not permitted on a list.
//
//----------------------------------------------------------------------------


public class RefIndexedList<T> extends RefUnsortedList<T>
                                 implements IndexedListInterface<T> {

   public RefIndexedList() {
      super();
   }

   public void add(int index, T element) {
   // Throws IndexOutOfBoundsException if passed an index argument
   // such that index < 0 or index > size().
   // Otherwise, adds element to this list at position index; all current
   // elements at that index or higher have 1 added to their index.

      if ((index < 0) || (index > size()))
         throw new IndexOutOfBoundsException("illegal index of " + index +
                                " passed to RefIndexedList add method.\n");
      LLNode<T> newnode = new LLNode<T>(element);
      find(index);
      if (location == list) {
		  // add to beginning of list: change list
		  newnode.setLink(location);
		  list = newnode;
	  }
	  else {
		  //add somewhere else: change link of previous node
		  newnode.setLink(location);
		  previous.setLink(newnode);
	  }
	  numElements++;
   }

   public T set(int index, T element) {
   // Throws IndexOutOfBoundsException if passed an index argument
   // such that index < 0 or index >= size().
   // Otherwise, replaces element on this list at position index and
   // returns the replaced element.
      if ((index < 0) || (index >= size()))
         throw new IndexOutOfBoundsException("illegal index of " + index +
                                " passed to ArrayIndexedList set method.\n");

      find(index);
      T hold = location.getInfo();
      location.setInfo(element);
      return hold;
   }

   public T get(int index) {
   // Throws IndexOutOfBoundsException if passed an index argument
   // such that index < 0 or index >= size().
   // Otherwise, returns the element on this list at position index.
      if ((index < 0) || (index >= size()))
         throw new IndexOutOfBoundsException("illegal index of " + index +
                               " passed to ArrayIndexedList set method.\n");

      find(index);
      return location.getInfo();
   }

   public int indexOf(T element) {
   // If this list contains an element e such that e.equals(element),
   // then returns the index of the first such element.
   // Otherwise, returns -1.
      int count = 0;
      location = list;

      while (location != null) {
         if (location.getInfo().equals(element)) { // if they match
            return count;
         }
         else {
            previous = location;
            location = location.getLink();
            count++;
         }
      }
      return -1;
   }

   public T remove(int index) {
   // Throws IndexOutOfBoundsException if passed an index argument
   // such that index < 0 or index >= size().
   // Otherwise, removes element on this list at position index and
   // returns the removed element; all current elements at positions
   // higher than that index have 1 subtracted from their index.
      if ((index < 0) || (index >= size()))
         throw new IndexOutOfBoundsException("illegal index of " + index +
                                " passed to ArrayIndexedList remove method.\n");

      find(index);
      T hold = location.getInfo();
      if (location == list) {
         // remove first item: change list
         list = location.getLink();
	  }
	  else {
	     previous.setLink(location.getLink());
	  }
      numElements--;
      return hold;
   }

   protected void find(int index) {
   // Searches list for the element in location index. If successful,
   // it sets instance variables found to true, location to node
   // containing e, and previous to the node that links to location.
   // If not successful, sets found to false.
      location = list;
      found = false;
      int count = 0;

      while (location != null) {
         if (count == index) { // if they match
            found = true;
            return;
         }
         else {
            previous = location;
            location = location.getLink();
            count++;
         }
      }
   }

   public T shcopy()//creates shallow copy of the list, new nodes to point to list elements, but not
   //create copies of the list elements, so original list and new list will point to the same objects
   //Should then return the new RefIndexedList
   {
	   LLNode<T> newnode = new LLNode<T>();
	   newnode.setlink(list);
	   list = newnode;
   }
}



Alright, so these are the given classes, first thing i have to do is make a shcopy method in the RefIndexedList class which would make a
shallow copy of the list from RefUnsortedList, this means that the method will create new LLNodes to point to the list elements, but it will not create copies of the list elements. Thus the original list and the clone will point to the same objects.

Here is my attempt at making that method:
public T shcopy()//creates shallow copy of the list, new nodes to point to list elements, but not
   //create copies of the list elements, so original list and new list will point to the same objects
   //Should then return the new RefIndexedList
   {
	   LLNode<T> newnode = new LLNode<T>();
	   newnode.setlink(list);
	   list = newnode;
   }



When I compile I get these errors that I really don't understand:

F:\CSC236Java\KevinPatelLab3\RefIndexedList.java:141: error: constructor LLNode in class LLNode<T#2> cannot be applied to given types;
LLNode<T> newnode = new LLNode<T>();
^
required: T#1
found: no arguments
reason: actual and formal argument lists differ in length
where T#1,T#2 are type-variables:
T#1 extends Object declared in class RefIndexedList
T#2 extends Object declared in class LLNode
F:\CSC236Java\KevinPatelLab3\RefIndexedList.java:142: error: cannot find symbol
newnode.setlink(list);
^
symbol: method setlink(LLNode<T>)
location: variable newnode of type LLNode<T>
where T is a type-variable:
T extends Object declared in class RefIndexedList
2 errors

Tool completed with exit code 1

How can I go about changing the method(no parameters) to get my program to compile? I tried changing it different ways, for example instead of public T
I changed it to public void and that didn't help so I changed it back. From what I think, I think its the code inside the method. But I don't know what
Im doing wrong, so can someone help me get through this lab? thanks in advance.
Was This Post Helpful? 0
  • +
  • -

#13 Preacher2012   User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 158
  • Joined: 02-November 12

Re: cypher program help

Posted 30 March 2014 - 05:14 PM

can someone help be figure out how to fix my shcopy method that I posted above?
Was This Post Helpful? 0
  • +
  • -

#14 andrewsw   User is offline

  • head thrashing
  • member icon

Reputation: 6627
  • View blog
  • Posts: 27,088
  • Joined: 12-December 12

Re: cypher program help

Posted 30 March 2014 - 05:27 PM

Quote

so why try waste time? I dont know but thanks for trying

I didn't waste time, I helped you to fix errors in your code.

But I won't waste any more time. Hopefully someone else will advise you. Good luck.

This post has been edited by andrewsw: 30 March 2014 - 05:28 PM

Was This Post Helpful? 1
  • +
  • -

#15 Preacher2012   User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 158
  • Joined: 02-November 12

Re: cypher program help

Posted 30 March 2014 - 05:29 PM

anyone? please?
Was This Post Helpful? 0
  • +
  • -

  • (3 Pages)
  • +
  • 1
  • 2
  • 3