Question
Please help me to make a java project on eclipse with only two java pages called Unsorted List and Sorted List that need to follow
Please help me to make a java project on eclipse with only two java pages called Unsorted List and Sorted List that need to follow the TODO tags to implement the method. Please keep in mind we only allow to implement the method for the two java pages.
program does not compile will receive grade of zero. Place your code in a class named UnsortedList, SortedList, and optionally AbstractShape, Triangle, Rectangle, Square, and Circle.
There is no need for a main method in this assignment but feel free to create another Test class to test your UnsortedList and SortedList. Please DO NOT add any extra method or field for those two classes.For the class UnsortedList:
Implement the method insert to add an item and always put it in the back of the list. If the item's value is null then the program should throw NullPointerException.
Implement the method remove to find the item in the list. If the item is found, we remove it from the list and return that item (we do not want to lose the connection of the item removed). If the item is not found, simply return null. If the item's value is null then the program should throw NullPointerException.
Implement the method removeAtIndex to remove the item at the given index. We remove the item from the list and return that item (we do not want to lose the connection of the item removed). If the index is negative or out of bound then the program should throw IndexOutOfBoundsException.
Implement the method get to get the item at the given index by returning the value. If the index is negative or out of bound then the program should throw IndexOutOfBoundsException.
Implement the method set to set the item at the given index. If the index is negative or out of bound then the program should throw IndexOutOfBoundsException. If the value of the item is null then the program should throw NullPointerException.
Implement the method contains to check if the item is in the list. The method returns true if the item is in the list otherwise false. If the value of the item is null then the program should throw NullPointerException.
Implement the method clear to clear/empty the list.
For the class SortedList. We implement all methods insert, remove, removeAtIndex, get, contains, and clear same as UnsortedList but except the set method. We do not want to mess up the order of the list.
Be sure your code follows the naming and coding conventions for the class:
Instance fields of a class should be named starting with 'my'
Parameters to methods should be named starting with 'the'
Parameters to methods should be specified as final
Javadoc comments should be used for the class as well as the methods of the class
You will lose points for each of these things on every assignment if you do not adhere to the rules.
See this document for specifics (as well as an example): https://www.oracle.com/java/technologies/javase/codeconventions-introduction.html
Download:
List.java (do not modify the content of this file)
AbstractList.java (do not modify the content of this file)
UnsortedList.java (follow the TODO tags to implement methods)
SortedList.java (follow the TODO tags to implement methods)
readme.txt (example)
Submission:
Submit to Canvas a zip file named assignment04_LASTNAME_FIRSTNAME.zip (all lower cases) that contains the following files: (assignment04_hoang_varik.zip for example)
Here is a list of files that you need to submit:
UnsortedList.java
SortedList.java
A readme.txt file that contains the following information
Your name
An estimate of the amount of time you spent completing the assignment
Any problems that exist in the project (if there are not any please state so)
Any questions you have for Varik about the assignment
Rubric:
Points | Categories | Comments |
---|---|---|
- | Functionality | Compiled source code with error(s) will receive a grade of zero |
- | Functionality | Compiled source code with no error and no infinite run. |
10 | Functionality | The class UnsortedList had method insert worked correctly. |
12 | Functionality | The class UnsortedList had method remove and removeAtIndex worked correctly. |
10 | Functionality | The class UnsortedList had method get and set worked correctly. |
5 | Functionality | The class UnsortedList had method contains worked correctly. |
3 | Functionality | The class UnsortedList had method clear worked correctly. |
20 | Functionality | The class SortedList had method insert worked correctly. |
20 | Functionality | The class SortedList had method remove and removeAtIndex worked correctly. |
5 | Functionality | The class SortedList had method get worked correctly. |
5 | Functionality | The class SortedList had method contains worked correctly. |
3 | Functionality | The class SortedList had method clear worked correctly. |
5 | Miscellaneous | Compressed files as expected |
2 | Miscellaneous | Used spacing, indentation appropriately and consistently |
100 | Total |
Note: must pass all criterias if using LGS
References:
History:
Versions | Date | Authors | Changes |
---|---|---|---|
1.0 | 04/10/2022 | Varik Hoang | Document created |
1.1 | 07/26/2022 | Varik Hoang | Moved all the shapes to extra credit part |
1.2 | 07/27/2022 | Varik Hoang | Added more detail in the implementation guildlines |
1.3 | 12/19/2022 | Varik Hoang | Removed the extra credit with shapes |
import java.util.Iterator; /** * Represents List interface. * * @author Varik Hoang * @version Sep 26, 2016 * @paramis of any object type. */ public interface List { /** * The method returns the current number of elements in the list. * * @return the current number of elements in the list greater than or equal 0 */ public int getSize(); /** * The method returns whether the list is empty. * * @return true if list is empty, false otherwise. */ public boolean isEmpty(); /** * The method returns whether value is in the list. * * @param value the value is assigned * @return true if value in the list, false otherwise. */ public boolean contains(Type value); /** * The method inserts an element into the list. * * @param value the value is assigned */ public void insert(Type value); /** * The method clears the list. */ public void clear(); /** * The method returns a string representation of list contents. * * @return a string representation of list contents. * @see Object#toString() */ @Override public String toString(); /** * /** * The method removes first element occurrence from the list. * * @param value the value is assigned * @return the removed value */ public Type remove(Type value); /** * The method returns the index of value. * * @param value the value is assigned. * @return the index of value if in the list, -1 otherwise. */ public int getIndex(Type value); /** * The method removes value at the given index. * * @param index the index must be in range of 0 and size * @return the removed value * @throws IndexOutOfBoundsException if index less than 0 or index greater than * or equal size */ public Type removeAtIndex(int index); /** * The method replaces the value at the given index with the given value. * * @param index the index must be in range of 0 and size * @param value the value is assigned * @throws IndexOutOfBoundsException if index less 0 or index greater than size */ public void set(int index, Type value); /** * Returns the value at the given index in the list. * * @param index the index must be in range of 0 and size * @throws IndexOutOfBoundsException if index less than 0 or greater size * @return the value at the given index in the list. */ public Type get(int index); /** * The method returns an iterator for this list. * * @return an iterator for the list. */ public Iterator iterator(); }
this is the abstractList.java
import java.util.Iterator; import java.util.NoSuchElementException; /** * The abstract class provides basic structure of the circular * linked list with the tail and size references * * @author Varik Hoang* * @param is any object type */ public abstract class AbstractList implements List { /** * The reference to the last element */ protected ListNode tail; /** * The size of the list */ protected int size; /** * The constructor that initiate the tail and size references */ public AbstractList() { tail = null; size = 0; } @Override public int getSize() { return size; } @Override public boolean isEmpty() { return size == 0; } @Override public int getIndex(final Type value) { if (value == null) throw new NullPointerException("The value could not be null"); if (tail == null) return -1; ListNode current = tail.next; // point to head for (int index = 0; index < size; index++) { if (current.data.equals(value)) return index; current = current.next; } return -1; } @Override public String toString() { if (size == 0) return "[]"; StringBuilder builder = new StringBuilder(); builder.append("["); ListNode current = tail.next; // head node while (current != tail) { builder.append(current.data).append(",").append(" "); current = current.next; } builder.append(tail.data); builder.append("]"); return builder.toString(); } /** * Returns an iterator for this list. * * @return an iterator for the list. */ public Iterator iterator() { return new LinkedIterator(); } /** * Represents a list node. * * @author Building Java Programs 3rd ed. * @param is of any object type */ protected static class ListNode { /** * Data stored in this node. */ public final Type data; /** * Link to next node in the list. */ public ListNode next; /** * Constructs a node with given data and a null link. * * @param data assigned */ public ListNode(Type data) { this(data, null); } /** * Constructs a node with given data and given link. * * @param data assigned * @param next assigned */ public ListNode(Type data, ListNode next) { this.data = data; this.next = next; } /** * The method returns the generic data type as string */ public String toString() { return this.data.toString(); } } /** * The iterator class for the list. * * @author modified from BuildingJavaPrograms 3rd Edition */ public class LinkedIterator implements Iterator { /** * Location of current value to return. */ private ListNode current; /** * The flag that tells if the first node has been visited. */ private boolean visited; /** * Constructs an iterator for the given list. */ public LinkedIterator() { reset(); } /** * Returns whether there are more list elements. * * @return true if there are more elements left, false otherwise * @see java.util.Iterator#hasNext() */ public boolean hasNext() { if (tail != null) return !(current == tail.next && visited); else return false; } /** * Returns the next element in the iteration. * * @throws NoSuchElementException if no more elements. * @return the next element in the iteration. * @see java.util.Iterator#next() */ public Type next() { if (!hasNext()) { throw new NoSuchElementException(); } Type result = current.data; current = current.next; visited = true; return result; } /** * This method is not supported */ public void remove() { throw new IllegalStateException("This iterator does not support remove operation"); } /** * The method resets back to the beginning. */ public final void reset() { if (tail != null) current = tail.next; visited = false; } } }
This is the two given java pages please DO NOT MODIFY THEM. You only need to make 2 more pages which is the UnsortedList.java and the SortedList.java classes. Thank you very much please complete the assignment with no error, passed all the sanity check on HuskyMap thank you.
This is the page where we check the code.
HuskyMap
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started