*UPDATE ASSIGNMENT ; Posted yesterday, but assignment due date is extended*
*DUE DATE: APRIL 13th, 2021 @ 10:00PM EST**
Your arraylist should be named AList.java
The arraylist will be tested with an object called Person (see attached) and integers.
The txt files show expected output with unaltered list testers.
// Program Description: The program will implement a structure similar to Java’s ArrayList,
// but using a Node based Doubly Linked List.
// File name: AListADT.java (Array List Abstract Data Type)
// File description: This is a Java Interface that provides the ADT to be used to implement the DLLAList class.
// This interface uses generics.
// AList.java should implement this interface, using generics as well.
// Files in this program:
// To be written by student: AList.java
// Provided by previous work: DLL.java, DLLADT.java, DLLNode.java
// Provided by professor: AListADT.java, AListTesterPerson.java, AListTesterInteger.java, Person.java
// Note: DO NOT MODIFY the provided files
// Revision History:
// Date: By: Action:
// —————————————————
// 3/1/17 mb created
// 6/18/10 jk updated
// Constructor: AList(): creates an empty list
public interface AListADT
// Returns the number of elements in this list.
public int size();
// Returns true if this list contains no elements.
public boolean isEmpty();
// Appends the specified element to the end of this list. (at the tail end.)
// Returns: true
public boolean add(E element);
// Inserts the specified element at the specified position in this list.
public void add(int index, E element) throws IndexOutOfBoundsException;
// Returns the element at the specified position in this list.
public E get(int index) throws IndexOutOfBoundsException;
// Replaces the element at the specified position in this list with the specified element.
// Returns: the element previously at the specified position (i.e. the old element that was replaced.)
public E set(int index, E element) throws IndexOutOfBoundsException;
// Returns the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element.
public int indexOf(E element);
// Returns true if this list contains the specified element, false otherwise
public boolean contains(E element);
// Removes the element at the specified position in this list.
// Returns: the element that was removed from the list
public E remove(int index) throws IndexOutOfBoundsException;
// Removes the first occurrence of the specified element from this list, if it is present.
// Returns: true if this list contained the specified element, false otherwise
public boolean remove(E e);
//boolean remove(Object o);
// Returns a string containing all the elements of the list that matches the output format of the spec
public String toString() ;
// AList.java must also contain the following “worker” method that is used by several of the methods above.
// Find non-sentinel node at 0 based position (i.e. first non-sentinel node is at index 0)
// private DLLNode
}
package A3DLL;
// Program: A3DLL
// Written by: Margie Bleichman
// Program Description: The program will implement a structure like Java’s ArrayList,
// using a Node based Doubly Linked List using Sentinels.
// File name: ListTester1.java (List client)
// File description: This is a tester for an index-based List Class implemented using generics.
// Files in this program:
// To be written by student: DLL.java
// Provided by professor: DLLADT.java, DLLNode.java, DLLTesterInteger
// Note: DO NOT MODIFY the provided files
// Revision History:
// Date: By: Action:
// —————————————————
// 3/1/17 mb created
public class DLLTesterInteger
{
public static void main (String[] args){
Integer i;
DLL
Integer n;
System.out.println (“DLLTesterInteger Output:\n”);
try {
System.out.println (L); // this one is EMPTY
n = 11; L.insertLastItem(n);
System.out.print(“Inserted Last: ” + n + “. “); System.out.println (L);
n = 33; L.insertLastItem(n);
System.out.print(“Inserted Last: ” + n + “. “); System.out.println (L);
n = 55; L.insertLastItem( n);
System.out.print(“Inserted Last: ” + n + “. “); System.out.println (L);
System.out.print(“There are ” + L.size() + ” items in the list. “);
System.out.print(“First: ” + L.getFirstItem() + “. “);
System.out.println(“Last: ” + L.getLastItem() + “. “);
System.out.print(“Removed First: ” + L.removeFirstItem() +”. “);System.out.println (L);
System.out.print(“Removed Last: ” + L.removeLastItem() +”. “); System.out.println (L);
System.out.println(“There are ” + L.size() + ” items in the list. “);
System.out.println(“Is the list empty? “+L.isEmpty());
n = 22; L.insertFirstItem( n);
System.out.print(“Inserted First: ” + n + “. “); System.out.println (L);
n = 44; L.insertLastItem( n);
System.out.print(“Inserted Last: ” + n + “. “); System.out.println (L);
n = 66; L.insertFirstItem( n);
System.out.print(“Inserted First: ” + n + “. “); System.out.println (L);
System.out.print(“There are ” + L.size() + ” items in the list. “);
System.out.print(“First: ” + L.getFirstItem() + “. “);
System.out.println(“Last: ” + L.getLastItem() + “. “);
System.out.println();
System.out.print(“Removed First Item: ” + L.removeFirstItem() +”. “);System.out.println (L);
System.out.print(“Removed Last Item: ” + L.removeLastItem() +”. “);System.out.println (L);
System.out.println(“There are ” + L.size() + ” items in the list. “);
System.out.print(“Removed First Item: ” + L.removeFirstItem() + “. “);System.out.println (L);
System.out.print(“Removed Last Item: ” + L.removeLastItem() + “. “);System.out.println (L);
System.out.println(“Is the list empty? ” + L.isEmpty());
// The following should force an exception if we uncomment it:
// System.out.println(“The next removeFirst() should force an exception: “);
// System.out.print(“Removed First: ” + L.removeFirstItem() + “. “);System.out.println (L);
}
catch (Exception e)
{System.out.println (“Error: “+ e.getMessage());}
}
}
package A3DLL;
// Program Description: The program will implement a structure like Java’s ArrayList, using a Node based Doubly Linked List.
// File name: DLLNode.java
// File description: This is the DLLNode class.
// DLL.java should use this DLLNode.
// Files in this program:
// To be written by student: DLL.java
// Provided by professor: DLLADT.java, DLLNode.java, DLLTesterInteger
// Note: DO NOT MODIFY the provided files
// Revision History:
// Date: By: Action:
// —————————————————
// 3/1/17 mb created
public class DLLNode
private E element;
private DLLNode
private DLLNode
// empty constructor, creates DLLNode with everything set to null
// pre-conditions: none
// post-conditions: returns a reference to a new instance of a DLLNode element
public DLLNode(){}
// constructor: takes element, previous node, next node
// pre-conditions: none
// post-conditions: returns a reference to a new instance of a DLLNode element
// prev, next are set to parameter values
public DLLNode(E e, DLLNode
element = e;
prev = p;
next = n;
}
// get the element
// pre-conditions: none
// post-conditions: element is returned
public E getElement(){return element;}
// get previous node
// pre-conditions: none
// post-conditions: previous node reference is returned
public DLLNode
// get next node
// pre-conditions: none
// post-conditions: next node reference is returned
public DLLNode
// set element
// pre-conditions: none
// post-conditions: element is replaced with parameter
public void setElement(E e){element = e;}
// set previous node
// pre-conditions: none
// post-conditions: previous is replaced with parameter
public void setPrevNode(DLLNode
// set next node
// pre-conditions: none
// post-conditions: next is replaced with parameter
public void setNextNode(DLLNode
// set all references in node to null
// (used to prepare for garbage collection)
// pre-conditions: none
// post-conditions: element, next, prev are all set to null
public void nullify (){ element = null; next = prev = null;}
// return a string representation of the node
// pre-conditions: none
// post-conditions: returns toString of the element
public String toString () {return “”+element;}
}
// Program Description: The program will implement an Index-based List with a Node based Singly Linked List.
// File name: Person.java
// File description: This is a simple class to be used with one of the testers.
// Files in this program: This class is used by various projects.
// Revision History:
// Date: By: Action:
// —————————————————
// 03/15/2012 (mb) Created
public class Person {
static int IDgenerator = 1;
private String name;
private int ID;
public Person (String sName) {
setName(sName); ID=IDgenerator++;}
public int getID(){return ID;}
public String getName(){ return name;}
public void setName(String sName) {name = sName;}
public String toString (){ return “(“+name + “-” + ID +”)”;}
// two Person objects are considered equal if their ID’s are equal
public Boolean equals(Person p){ return ID==p.getID(); }
}
package A4AList;
// Program Description: The program will implement an Index-based List with a Node based Singly Linked List.
// File name: ListTester2.java (List client)
// File description: This is a tester for an Index-based List Class implemented using generics.
// Files in this program:
// To be written by student: DLL.java, AList.java
// Provided by professor: DLLADT.java, DLLNode.java
// AListTesterPerson.java, AListTesterInteger.java, Person.java
// Note: DO NOT MODIFY the provided files
// Revision History:
// Date: By: Action:
// —————————————————
// 3/20/18 mb created
// 9/20/2020 jk updated with bug fixes
public class ListTester2
{
public static void main (String[] args){
AList
int i, j;
Person a, b, c, d, e, f, g, h, k, l, m, p;
a = new Person (“Amy”);
b = new Person (“Bob”);
c = new Person (“Cal”);
d = new Person (“Dot”);
e = new Person (“Eli”);
f = new Person (“Fay”);
g = new Person (“Gil”);
h = new Person (“Hop”);
k = new Person (“Kim”);
l = new Person (“Lee”);
m = new Person (“Mak”);
try{
System.out.println (“Testing add(element):”);
System.out.println (L); // this one is EMPTY
L.add(a); System.out.print(“Item added: ” + a + “. “); System.out.println (L);
L.add(b); System.out.print(“Item added: ” + b + “. “); System.out.println (L);
L.add(c); System.out.print(“Item added: ” + c + “. “); System.out.println (L);
L.add(d); System.out.print(“Item added: ” + d + “. “); System.out.println (L);
System.out.println (“\nTesting add(index, element):”);
L.add( 2, e); System.out.print(“Item inserted at index 2: “+ e + “. “); System.out.println (L);
L.add( 4, f); System.out.print(“Item inserted at index 4: “+ f + “. “); System.out.println (L);
System.out.println (“\nTesting get(index):”);
System.out.println(“There are ” + L.size() + ” items in the list: “);
for ( i=0; i
else System.out.println(“The AList does not contain ” + g);
i = L.indexOf(m);
if (i>=0) System.out.println(“The first occurrence of ” +m+” is at index: ” + i); // uses comparison! use .equals!
else System.out.println(“The AList does not contain “+ m + “. “);
System.out.println();
j=L.size(); package A4AList; System.out.println (“\nTesting add(index, element):”); package A3DLL; // provide the number of items in the list // return the last item without removing it // Add an item to the front of the list // Add an item to the end of the list // Remove an item from the end of the list // a method that can be used to get a string representing the whole list Testing add(element): Testing add(element):
for ( i=0; i
// Program Description: The program will implement an index-based List with a Node based Singly Linked List.
// File name: ListTester1.java (List client)
// File description: This is a tester for an index-based List Class implemented using generics.
// Files in this program:
// To be written by student: DLL.java, AList.java
// Provided by professor: DLLADT.java, DLLNode.java
// AListTesterPerson.java, AListTesterInteger.java, Person.java
// Note: DO NOT MODIFY the provided files
// Revision History:
// Date: By: Action:
// —————————————————
// 3/20/18 mb created
// 9/20/2020 jk updated with bug fixes
public class ListTester1
{
public static void main (String[] args){
int i,j;
AList
Integer n;
try {
System.out.println (“Testing add(element):”);
System.out.println (L); // this one is EMPTY
n = 11; L.add(n);
System.out.print(“Item added: ” + n + “. “); System.out.println (L);
n = 33; L.add(n);
System.out.print(“Item added: ” + n + “. “); System.out.println (L);
n = 55; L.add( n);
System.out.print(“Item added: “+ n + “. “); System.out.println (L);
n = 77; L.add( n);
System.out.print(“Item added: “+ n + “. “); System.out.println (L);
n = 200; L.add( 2, n);
System.out.print(“Item inserted at index 2: “+ n + “. “); System.out.println (L);
n = 400; L.add( 4, n);
System.out.print(“Item inserted at index 4: “+ n + “. “); System.out.println (L);
System.out.println (“\nTesting get(index):”);
System.out.println(“There are ” + L.size() + ” items in the list: “);
for ( i=0; i
else System.out.println(“The AList does not contain ” + n);
n = 10; i = L.indexOf(n);
if (i>=0) System.out.println(“The first occurrence of ” +n+” is at index: ” + i); // uses comparison! use .equals!
else System.out.println(“The AList does not contain “+ n + “. “);
System.out.println();
for ( i=0; i
// Program: A3DLL
// Written by: Margie Bleichman
// Program Description: The program will implement a structure like Java’s ArrayList,
// using a Node based Doubly Linked List using Sentinels.
// File name: DLLADT.java (Doubly Linked List Abstract Data Type)
// File description: This is a Java Interface that provides the ADT to be used to implement the DLL class.
// This interface uses generics.
// DLL.java should implement this interface, using generics as well.
// Files in this program:
// To be written by student: DLL.java
// Provided by professor: DLLADT.java, DLLNode.java, DLLTesterInteger
// Note: DO NOT MODIFY the provided files
// Revision History:
// Date: By: Action:
// —————————————————
// 3/1/17 mb created
import java.util.NoSuchElementException;
public interface DLLADT
public int size() ;
// is the list empty?
public boolean isEmpty() ;
// return the first item without removing it
public E getFirstItem() throws NoSuchElementException ;
public E getLastItem() throws NoSuchElementException ;
public void insertFirstItem(E element) ;
public void insertLastItem(E element) ;
// Remove an item from the front of the list
// Throws: NoSuchElementException – if this list is empty ;
public E removeFirstItem () throws NoSuchElementException ;
// Throws: NoSuchElementException – if this list is empty ;
public E removeLastItem() throws NoSuchElementException;
public String toString() ;
}
The Alist:{}
Item added: 11. The Alist:{11}
Item added: 33. The Alist:{11,33}
Item added: 55. The Alist:{11,33,55}
Item added: 77. The Alist:{11,33,55,77}
Testing add(index, element):
Item inserted at index 2: 200. The Alist:{11,33,200,55,77}
Item inserted at index 4: 400. The Alist:{11,33,200,55,400,77}
Testing get(index):
There are 6 items in the list:
Item(0): 11. Item(1): 33. Item(2): 200. Item(3): 55. Item(4): 400. Item(5): 77.
Items added: 22, 44, 66, 88.
The Alist:{11,33,200,55,400,77,22,44,66,88}
There are 10 items in the list,
Testing set(index, element):
Set Item(4) to 22. The Alist:{11,33,200,55,22,77,22,44,66,88}
Set Item(8) to 44. The Alist:{11,33,200,55,22,77,22,44,44,88}
Testing contains(element):
The AList contains 77.
The AList does not contain 123.
Testing remove(index):
Removed Item(3): 55. The Alist:{11,33,200,22,77,22,44,44,88}
Removed Item(5): 22. The Alist:{11,33,200,22,77,44,44,88}
There are 8 items in the list.
Testing remove(element):
Removed item containing 11. The Alist:{33,200,22,77,44,44,88}
Cannot remove 99. Not in AList.
Testing indexOf(element):
The first occurrence of 44 is at index: 4
The AList does not contain 10.
Reset AList elements to 0-6.
The Alist:{0,1,2,3,4,5,6}
Is the list empty? false
Removed Item(0): 0 The Alist:{1,2,3,4,5,6}
Removed Item(0): 1 The Alist:{2,3,4,5,6}
Removed Item(0): 2 The Alist:{3,4,5,6}
Removed Item(0): 3 The Alist:{4,5,6}
Removed Item(0): 4 The Alist:{5,6}
Removed Item(0): 5 The Alist:{6}
Removed Item(0): 6 The Alist:{}
Is the list empty? true
The Alist:{}
Item added: (Amy-1). The Alist:{(Amy-1)}
Item added: (Bob-2). The Alist:{(Amy-1),(Bob-2)}
Item added: (Cal-3). The Alist:{(Amy-1),(Bob-2),(Cal-3)}
Item added: (Dot-4). The Alist:{(Amy-1),(Bob-2),(Cal-3),(Dot-4)}
Testing add(index, element):
Item inserted at index 2: (Eli-5). The Alist:{(Amy-1),(Bob-2),(Eli-5),(Cal-3),(Dot-4)}
Item inserted at index 4: (Fay-6). The Alist:{(Amy-1),(Bob-2),(Eli-5),(Cal-3),(Fay-6),(Dot-4)}
Testing get(index):
There are 6 items in the list:
Item(0): (Amy-1). Item(1): (Bob-2). Item(2): (Eli-5). Item(3): (Cal-3). Item(4): (Fay-6). Item(5): (Dot-4).
Items added: Gil,Hop,Kim,Lee.
The Alist:{(Amy-1),(Bob-2),(Eli-5),(Cal-3),(Fay-6),(Dot-4),(Gil-7),(Hop-8),(Kim-9),(Lee-10)}
There are 10 items in the list,
Testing set(index, element):
Set Item(4) to (Gil-7).The Alist:{(Amy-1),(Bob-2),(Eli-5),(Cal-3),(Gil-7),(Dot-4),(Gil-7),(Hop-8),(Kim-9),(Lee-10)}
Set Item(8) to (Hop-8).The Alist:{(Amy-1),(Bob-2),(Eli-5),(Cal-3),(Gil-7),(Dot-4),(Gil-7),(Hop-8),(Hop-8),(Lee-10)}
Testing contains(element):
The AList contains (Dot-4).
The AList does not contain (Mak-11).
Testing remove(index):
Removed Item(3): (Cal-3). The Alist:{(Amy-1),(Bob-2),(Eli-5),(Gil-7),(Dot-4),(Gil-7),(Hop-8),(Hop-8),(Lee-10)}
Removed Item(5): (Gil-7). The Alist:{(Amy-1),(Bob-2),(Eli-5),(Gil-7),(Dot-4),(Hop-8),(Hop-8),(Lee-10)}
There are 8 items in the list.
Testing remove(element):
Removed item containing (Amy-1). The Alist:{(Bob-2),(Eli-5),(Gil-7),(Dot-4),(Hop-8),(Hop-8),(Lee-10)}
Cannot remove (Mak-11). Not in AList.
Testing indexOf(element):
The first occurrence of (Gil-7) is at index: 2
The AList does not contain (Mak-11).
Removed Item(0): (Bob-2) The Alist:{(Eli-5),(Gil-7),(Dot-4),(Hop-8),(Hop-8),(Lee-10)}
Removed Item(0): (Eli-5) The Alist:{(Gil-7),(Dot-4),(Hop-8),(Hop-8),(Lee-10)}
Removed Item(0): (Gil-7) The Alist:{(Dot-4),(Hop-8),(Hop-8),(Lee-10)}
Removed Item(0): (Dot-4) The Alist:{(Hop-8),(Hop-8),(Lee-10)}
Removed Item(0): (Hop-8) The Alist:{(Hop-8),(Lee-10)}
Removed Item(0): (Hop-8) The Alist:{(Lee-10)}
Removed Item(0): (Lee-10) The Alist:{}
Is the list empty? true
We provide professional writing services to help you score straight A’s by submitting custom written assignments that mirror your guidelines.
Get result-oriented writing and never worry about grades anymore. We follow the highest quality standards to make sure that you get perfect assignments.
Our writers have experience in dealing with papers of every educational level. You can surely rely on the expertise of our qualified professionals.
Your deadline is our threshold for success and we take it very seriously. We make sure you receive your papers before your predefined time.
Someone from our customer support team is always here to respond to your questions. So, hit us up if you have got any ambiguity or concern.
Sit back and relax while we help you out with writing your papers. We have an ultimate policy for keeping your personal and order-related details a secret.
We assure you that your document will be thoroughly checked for plagiarism and grammatical errors as we use highly authentic and licit sources.
Still reluctant about placing an order? Our 100% Moneyback Guarantee backs you up on rare occasions where you aren’t satisfied with the writing.
You don’t have to wait for an update for hours; you can track the progress of your order any time you want. We share the status after each step.
Although you can leverage our expertise for any writing task, we have a knack for creating flawless papers for the following document types.
Although you can leverage our expertise for any writing task, we have a knack for creating flawless papers for the following document types.
From brainstorming your paper's outline to perfecting its grammar, we perform every step carefully to make your paper worthy of A grade.
Hire your preferred writer anytime. Simply specify if you want your preferred expert to write your paper and we’ll make that happen.
Get an elaborate and authentic grammar check report with your work to have the grammar goodness sealed in your document.
You can purchase this feature if you want our writers to sum up your paper in the form of a concise and well-articulated summary.
You don’t have to worry about plagiarism anymore. Get a plagiarism report to certify the uniqueness of your work.
Join us for the best experience while seeking writing assistance in your college life. A good grade is all you need to boost up your academic excellence and we are all about it.
We create perfect papers according to the guidelines.
We seamlessly edit out errors from your papers.
We thoroughly read your final draft to identify errors.
Work with ultimate peace of mind because we ensure that your academic work is our responsibility and your grades are a top concern for us!
Dedication. Quality. Commitment. Punctuality
Here is what we have achieved so far. These numbers are evidence that we go the extra mile to make your college journey successful.
We have the most intuitive and minimalistic process so that you can easily place an order. Just follow a few steps to unlock success.
We understand your guidelines first before delivering any writing service. You can discuss your writing needs and we will have them evaluated by our dedicated team.
We write your papers in a standardized way. We complete your work in such a way that it turns out to be a perfect description of your guidelines.
We promise you excellent grades and academic excellence that you always longed for. Our writers stay in touch with you via email.