Question
Please help me make a java programming project. There will be four pages that we don't need to be modifying them. Please follow the instructions
Please help me make a java programming project. There will be four pages that we don't need to be modifying them. Please follow the instructions below this website for more information!!! Please make sure everything compiles, passed all the sanity check that required. please read the instructions carefully!!!
The password and username are 202422777.
http://18.224.94.128/course/index.php?page=95
please help me make the classes below, please make sure they compile with no errors, passed all sanity checks.
LinkedDeque.java
- LinkedDequeTest.java (optional)
- RadixSort.java
- RadixSortMain.java
Do NoT modify these pages
Queue.java
/** * The class defines the Queue interface * * */ public interface Queue { /** * The method adds the specified element to the tail/rear/last of the queue. * @param data the element to add to the queue */ void add(Type data); /** * The method removes and returns the front/head element from the queue. * @throws EmptyCollectionException if the queue is empty. * @return the front/head element from the queue */ Type remove(); /** * The method eturns the front/head element from the queue (without removing the element. * * @throws EmptyCollectionException if the queue is empty. * @return the front element from the queue */ Type peek(); /** * The method indicates the number of elements in the queue * * @return the count of elements currently in the queue */ int size(); /** * The method checks if the queue is empty or not * * @return true if the queue contains no elements otherwise false */ boolean isEmpty(); }
Deque.java
public interface Deque extends Queue { /** * The method adds element to the back * @param data the element is added to the back */ void addRear(Type data); /** * The method adds element to the front * @param data the element is added to the front */ void addFront(Type data); /** * The method removes element from the back */ Type removeRear(); /** * The method removes element from the front */ Type removeFront(); /** * The method examines element from the back */ Type peekRear(); /** * The method examines the element from the front */ Type peekFront(); } /** * The class represents the exception when a collection is empty. */ public class EmptyCollectionException extends RuntimeException { private static final long serialVersionUID = 8084488539524488189L; /** * The constructor sets up this exception with an appropriate message. * @param message the error message */ public EmptyCollectionException(final String message) { super(message); } }
/** * The class defines a node-based queue. * @param the generic data type */ public class LinkedQueue implements Queue { /** * The number of elements contained in the queue. */ protected int size; /** * A reference to the first node in the queue. (The 'head' of the queue.) */ protected Node head; /** * A reference to the last node in the queue. (The 'tail' of the queue.) */ private Node tail; /** * The constructor initializes an empty queue. */ public LinkedQueue() { size = 0; head = null; tail = null; } @Override public void add(final Type theElement) { if (size == 0) { // base case when the queue is empty head = new Node(theElement); tail = head; } else { // regular case when the queue is not empty tail.next = new Node(theElement); tail = tail.next; } size++; } @Override public Type remove() { if (size == 0) throw new EmptyCollectionException("queue"); final Type returnValue = head.data; head = head.next; size--; return returnValue; } @Override public Type peek() { if (size == 0) { throw new EmptyCollectionException("queue"); } return head.data; } @Override public int size() { return size; } @Override public boolean isEmpty() { return size == 0; } /** * The method returns the linked queue in string format as below * * The format of the returned String is: Head -> 8, 6, 7, 5, 3, 0, 9 */ @Override public String toString() { if (size == 0) return "head ->"; final StringBuilder buffer = new StringBuilder(); buffer.append("head -> "); Node current = head; for (int i = 0; i < size - 1; i++) { buffer.append(current.data); buffer.append(", "); current = current.next; } buffer.append(current.data); return buffer.toString(); } /** * The class represents a node in a singly linked structure. * * @author Varik Hoang &..p@uw.edu> * @param generic data type */ protected class Node { /** * A reference to the next node in the linked structure. */ protected Node next; /** * A reference to the data element held in this node. */ protected final Type data; /** * The constructor initializes the node using the specified data element. * * @param data the data element held in this node */ Node(final Type data) { this(data, null); } /** * The constructor initializes the node using the specified data element and the specified next * node. * * @param data the data element held in this node * @param next the next node in the linked structure */ Node(final Type data, final Node next) { this.data = data; this.next = next; } } }