Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Use the java class ArrayList to implement your List class. I.e., your only insta

ID: 3862161 • Letter: U

Question

Use the java class ArrayList to implement your List class. I.e., your only instance data is

private ArrayList mList;

List class methods will delegate their functionality to ArrayList. Need help with the class List don't have to change anything from the main.

//Output:

//main

public class AssignmentFive
{
   public static void main(String[] args)
   {
       List myList = new List();
       List emptyList = new List(myList);
      
       // Cause List Empty Message
       myList.removeFront();
       myList.removeRear();
       myList.removeItem("a");
      
       // Cause Not found message
       myList.addToFront("x");
       myList.removeItem("y");
       myList.removeItem("x");
       myList.addAfterItem("x", "z");
       myList.addBeforeItem("x", "z");
          
       // Normal behavior
       myList.addToFront("not.");
       myList.addToFront("or");
       myList.addToRear("is");
       myList.addToRear("try.");
       myList.addAfterItem("is", "no");
       myList.addBeforeItem("is", "There");
       myList.addToFront("Do");
       myList.addAfterItem("or", "do");
      
       myList.print("Original list");
       myList.printSorted("Sorted Original List");
       emptyList.print("Empty List");
      
       List copyOfList = new List(myList);
          
       sop(" Front is " + myList.getFront());
       sop("Rear is " + myList.getRear());
       sop("Count is " + myList.askCount());
       sop("Is There present? " + myList.isPresent("There"));
       sop("Is Dog present? " + myList.isPresent("Dog"));
  
       myList.addToFront("junk");
       myList.addToRear("morejunk");
       myList.addAfterItem("or", "moremorejunk");
      
       myList.print("List with junk");
       sop("Count is " + myList.askCount());
      
       copyOfList.print("Untouched copy of the list");
      
       myList.removeFront();
       myList.removeRear();
       myList.removeItem("moremorejunk");
       myList.print("List with junk removed");
       sop("Count is " + myList.askCount());
       sop("");
      
       copyOfList.print("Untouched copy of the list");
      
       while(myList.askCount() > 0) myList.removeFront();
      
       myList.print("List after removing all items");
       copyOfList.print("Copy of List after removing all items");
   }
  
   private static void sop(String s)
   {
       System.out.println(s);
   }
}

//Class List:

public class List
{
   private Stirng[] mList;
   /**
   * Create a List with the indicated size
   * @param size the maximum number of items in the List
   */
   public List(int size)
   {
       mCount = 0;
       mList = new String[size];
   }
  
   /**
   * If the List is not full, item becomes the new front element
   * If the List is full, prints "List Full"
   * @param item the item to add
   */
   public void addToFront(String item)
   {

   }
  
   /**
   * If the List is not full, item becomes the new rear element
   * If the List is full, prints "List Full"
   * @param item the item to add
   */
   public void addToRear(String item)
   {
       if(mCount == mList.length)
       {
           sop("List Full");
       }
       else
       {
           mList[mCount] = item;
           mCount++;
       }
   }
  
   /**
   * If the List is not full and beforeItem is in the List item becomes the element before beforeItem
   * If the List is full, prints "List Full"
   * If List is not full but beforeItem is not in List, prints "Item Not Found"
   * @param beforeItem the item in the list to add item before
   * @param item the item to add
   */
   public void addBeforeItem(String beforeItem, String item)
   {
       if(mCount == mList.length)
       {
           sop("List Full");
       }
       else if(isPResent(beforeItem) && mCount < mList.Length))
       {
           if(find(beforeItem) == 0)
           {
              
           }
       else
       {
           sop("Item not found");
       }
   }
  
   /**
   * If the List is not full and afterItem is in the List item becomes the element after afterItem
   * If the List is full, prints "List Full"
   * If List is not full but afterItem is not in List, prints "Item Not Found"
   * @param afterItem the item in the list to add item before
   * @param item the item to add
   */
   public void addAfterItem(String afterItem, String item)
   {

   }
  
   /**
   * Returns the item at the front of the List (List is not altered)
   * @return the item at the front of the List
   */
   public String getFront()
   {
       if(mCount == 0)
       {
           sop("List Empty");
           return "";
       }
      
       return(mList[0]);
      
   }
  
   /**
   * Returns the item at the rear of the List (List is not altered)
   * @return the item at the rear of the List
   */
   public String getRear()
   {
       if(mCount == 0)
       {
           sop("List Empty");
           return "";
       }
      
       return(mList[mCount - 1]);
   }
  
   /**
   * Return true if item is in List, false otherwise
   * @param item to check presence in List
   * @return true if item is in List, false otherwise
   */
   public boolean isPresent(String item)
   {

   }
  
   /**
   * Returns the number of items in the List
   * @return the number of items in the List
   */
   public int askCount()
   {
       return(mCount);
   }
  
   /**
   * If the List is empty, prints "List Empty"
   * If the List is not empty, removes the item at the front of the List
   */
   public void removeFront()
   {

   }
  
   /**
   * If the List is empty, prints "List Empty"
   * If the List is not empty, removes the item at the rear of the List
   */
   public void removeRear()
   {
       if(mCount == 0)
       {
           sop("List Empty");
           return;
       }
       --mCount;
   }
  
   /**
   * If the List is empty, prints "List Empty"
   * If item is not present in List, prints "Item not found"
   * Otherwise, item is removed from the List
   * @param item the item to remove
   */
   public void removeItem(String item)
   {
       if(mCount == 0)
       {
           sop("List Empty");
           return;
       }
      
       int ii = find(item);
       if(ii != -1)
       {
           shiftLeft(ii);
           --mCount;
       }
       else
       {
           sop("Item not found");
       }
   }
  
   /**
   * Print title on a line by itself
   * Prints the List from front to rear with 1 space between each item
   * @param title the description of the List
   */
   public void print(String title)
   {
       System.out.println(" " + title);
       for(int ii = 0; ii < mCount; ++ii)
       {
           System.out.print(mList[ii] + " ");
       }
       System.out.println("");
   }
  
   /**
   * Print title on a line by itself
   * Prints the Sorted List with 1 space between each item
   * Does not alter the List
   * @param title the description of the List
   */
   public void printSorted(String title)
   {
       ArrayList tempList = new ArrayList();
       for(int ii = 0; ii < mCount; ++ii)
       {
           tempList.add(mList[ii]);
       }
      
       Collections.sort(tempList);
       System.out.println(" " + title);
       for(String s : tempList)
       {
           System.out.print(s + " ");
       }
      
       System.out.println("");
      
   }
  
}

Explanation / Answer

just copy this code it will solve your problem.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote