Question

In: Computer Science

please run it and show a sample. please dont change the methods. public interface PositionalList extends...

please run it and show a sample. please dont change the methods.

public interface PositionalList extends Iterable {

/**
* Returns the number of elements in the list.
* @return number of elements in the list
*/
int size();

/**
* Tests whether the list is empty.
* @return true if the list is empty, false otherwise
*/
boolean isEmpty();

/**
* Returns the first Position in the list.
*
* @return the first Position in the list (or null, if empty)
*/
Position first();

/**
* Returns the last Position in the list.
*
* @return the last Position in the list (or null, if empty)
*/
Position last();

/**
* Returns the Position immediately before Position p.
* @param p a Position of the list
* @return the Position of the preceding element (or null, if p is first)
* @throws IllegalArgumentException if p is not a valid position for this list
*/
Position before(Position p) throws IllegalArgumentException;

/**
* Returns the Position immediately after Position p.
* @param p a Position of the list
* @return the Position of the following element (or null, if p is last)
* @throws IllegalArgumentException if p is not a valid position for this list
*/
Position after(Position p) throws IllegalArgumentException;

/**
* Inserts an element at the front of the list.
*
* @param e the new element
* @return the Position representing the location of the new element
*/
Position addFirst(E e);

/**
* Inserts an element at the back of the list.
*
* @param e the new element
* @return the Position representing the location of the new element
*/
Position addLast(E e);

/**
* Inserts an element immediately before the given Position.
*
* @param p the Position before which the insertion takes place
* @param e the new element
* @return the Position representing the location of the new element
* @throws IllegalArgumentException if p is not a valid position for this list
*/
Position addBefore(Position p, E e)
throws IllegalArgumentException;

/**
* Inserts an element immediately after the given Position.
*
* @param p the Position after which the insertion takes place
* @param e the new element
* @return the Position representing the location of the new element
* @throws IllegalArgumentException if p is not a valid position for this list
*/
Position addAfter(Position p, E e)
throws IllegalArgumentException;

/**
* Replaces the element stored at the given Position and returns the replaced element.
*
* @param p the Position of the element to be replaced
* @param e the new element
* @return the replaced element
* @throws IllegalArgumentException if p is not a valid position for this list
*/
E set(Position p, E e) throws IllegalArgumentException;

/**
* Removes the element stored at the given Position and returns it.
* The given position is invalidated as a result.
*
* @param p the Position of the element to be removed
* @return the removed element
* @throws IllegalArgumentException if p is not a valid position for this list
*/
E remove(Position p) throws IllegalArgumentException;

/**
* Returns an iterator of the elements stored in the list.
* @return iterator of the list's elements
*/
Iterator iterator();

/**
* Returns the positions of the list in iterable form from first to last.
* @return iterable collection of the list's positions
*/
Iterable> positions();
}

import java.util.Iterator;

import Position; (interface)
import PositionalList;(interface)
public class DoublyLinkedList implements PositionalList
{
private int NumberofNode;
private Node head;
private Node tail;
   public DoublyLinkedList()
   {
       head = new Node();
       tail = new Node();
       head.next =tail;
       tail.prev = head;
   }

   @Override
   public int size()
   {
      
       return NumberofNode;
       return size;
   }

   @Override
   public boolean isEmpty()
   {
       if(NumberofNode < 1 )
           return true;
       else
           return false;
       //return size ==0;
   }

   @Override
   public Position first()
   {
       if(NumberofNode >=1)
           return head;
       return null;
   }

   @Override
   public Position last()
   {
       if(NumberofNode >= 1)
           return tail;
       return null;
   }

   @Override
   public Position before(Position p) throws IllegalArgumentException
   {
  
       return null;
   }

   @Override
   public Position after(Position p) throws IllegalArgumentException {
       // TODO Auto-generated method stub
       return null;
   }

   @Override
   public Position addFirst(E e) {
       // TODO Auto-generated method stub
       return null;
   }

   @Override
   public Position addLast(E e) {
       // TODO Auto-generated method stub
       return null;
   }

   @Override
   public Position addBefore(Position p, E e)
           throws IllegalArgumentException {
       // TODO Auto-generated method stub
       return null;
   }

   @Override
   public Position addAfter(Position p, E e)
           throws IllegalArgumentException {
       // TODO Auto-generated method stub
       return null;
   }

   @Override
   public E set(Position p, E e) throws IllegalArgumentException {
       // TODO Auto-generated method stub
       return null;
   }

   @Override
   public E remove(Position p) throws IllegalArgumentException {
       // TODO Auto-generated method stub
       return null;
   }

   @Override
   public Iterator iterator() {
       // TODO Auto-generated method stub
       return null;
   }

   @Override
   public Iterable> positions() {
       // TODO Auto-generated method stub
       return null;
   }
  
   public E removeFirst() throws IllegalArgumentException {
       // TODO Auto-generated method stub
       return null;
   }
  
   public E removeLast() throws IllegalArgumentException {
       // TODO Auto-generated method stub
       return null;
   }

}

Solutions

Expert Solution

Well there are erros in the above code which are shown below, also Position.java is missing in the code given above. Kindly look into this.

Errors:-

 javac -classpath .:/run_dir/junit-4.12.jar:target/dependency/* -d . Main.java PositionalList.java
Main.java:23: error: cannot find symbol
private Node head;
^
symbol: class Node
location: class DoublyLinkedList
Main.java:24: error: cannot find symbol
private Node tail;
^
symbol: class Node
location: class DoublyLinkedList
Main.java:52: error: cannot find symbol
public Position first()
^
symbol: class Position
location: class DoublyLinkedList
Main.java:60: error: cannot find symbol
public Position last()
^
symbol: class Position
location: class DoublyLinkedList
Main.java:68: error: cannot find symbol
public Position before(Position p) throws IllegalArgumentException
^
symbol: class Position
location: class DoublyLinkedList
Main.java:68: error: cannot find symbol
public Position before(Position p) throws IllegalArgumentException
^
symbol: class Position
location: class DoublyLinkedList
Main.java:75: error: cannot find symbol
public Position after(Position p) throws IllegalArgumentException {
^
symbol: class Position
location: class DoublyLinkedList
Main.java:75: error: cannot find symbol
public Position after(Position p) throws IllegalArgumentException {
^
symbol: class Position
location: class DoublyLinkedList
Main.java:81: error: cannot find symbol
public Position addFirst(E e) {
^
symbol: class E
location: class DoublyLinkedList
Main.java:81: error: cannot find symbol
public Position addFirst(E e) {
^
symbol: class Position
location: class DoublyLinkedList
Main.java:87: error: cannot find symbol
public Position addLast(E e) {
^
symbol: class E
location: class DoublyLinkedList
Main.java:87: error: cannot find symbol
public Position addLast(E e) {
^
symbol: class Position
location: class DoublyLinkedList
Main.java:93: error: cannot find symbol
public Position addBefore(Position p, E e)
^
symbol: class Position
location: class DoublyLinkedList
Main.java:93: error: cannot find symbol
public Position addBefore(Position p, E e)
^
symbol: class E
location: class DoublyLinkedList
Main.java:93: error: cannot find symbol
public Position addBefore(Position p, E e)
^
symbol: class Position
location: class DoublyLinkedList
Main.java:100: error: cannot find symbol
public Position addAfter(Position p, E e)
^
symbol: class Position
location: class DoublyLinkedList
Main.java:100: error: cannot find symbol
public Position addAfter(Position p, E e)
^
symbol: class E
location: class DoublyLinkedList
Main.java:100: error: cannot find symbol
public Position addAfter(Position p, E e)
^
symbol: class Position
location: class DoublyLinkedList
Main.java:107: error: cannot find symbol
public E set(Position p, E e) throws IllegalArgumentException {
^
symbol: class Position
location: class DoublyLinkedList
Main.java:107: error: cannot find symbol
public E set(Position p, E e) throws IllegalArgumentException {
^
symbol: class E
location: class DoublyLinkedList
Main.java:107: error: cannot find symbol
public E set(Position p, E e) throws IllegalArgumentException {
^
symbol: class E
location: class DoublyLinkedList
Main.java:113: error: cannot find symbol
public E remove(Position p) throws IllegalArgumentException {
^
symbol: class Position
location: class DoublyLinkedList
Main.java:113: error: cannot find symbol
public E remove(Position p) throws IllegalArgumentException {
^
symbol: class E
location: class DoublyLinkedList
Main.java:130: error: cannot find symbol
public E removeFirst() throws IllegalArgumentException {
^
symbol: class E
location: class DoublyLinkedList
Main.java:135: error: cannot find symbol
public E removeLast() throws IllegalArgumentException {
^
symbol: class E
location: class DoublyLinkedList
PositionalList.java:21: error: cannot find symbol
Position first();
^
symbol: class Position
location: interface PositionalList
PositionalList.java:28: error: cannot find symbol
Position last();
^
symbol: class Position
location: interface PositionalList
PositionalList.java:36: error: cannot find symbol
Position before(Position p) throws IllegalArgumentException;
^
symbol: class Position
location: interface PositionalList
PositionalList.java:36: error: cannot find symbol
Position before(Position p) throws IllegalArgumentException;
^
symbol: class Position
location: interface PositionalList
PositionalList.java:44: error: cannot find symbol
Position after(Position p) throws IllegalArgumentException;
^
symbol: class Position
location: interface PositionalList
PositionalList.java:44: error: cannot find symbol
Position after(Position p) throws IllegalArgumentException;
^
symbol: class Position
location: interface PositionalList
PositionalList.java:52: error: cannot find symbol
Position addFirst(E e);
^
symbol: class E
location: interface PositionalList
PositionalList.java:52: error: cannot find symbol
Position addFirst(E e);
^
symbol: class Position
location: interface PositionalList
PositionalList.java:60: error: cannot find symbol
Position addLast(E e);
^
symbol: class E
location: interface PositionalList
PositionalList.java:60: error: cannot find symbol
Position addLast(E e);
^
symbol: class Position
location: interface PositionalList
PositionalList.java:70: error: cannot find symbol
Position addBefore(Position p, E e)
^
symbol: class Position
location: interface PositionalList
PositionalList.java:70: error: cannot find symbol
Position addBefore(Position p, E e)
^
symbol: class E
location: interface PositionalList
PositionalList.java:70: error: cannot find symbol
Position addBefore(Position p, E e)
^
symbol: class Position
location: interface PositionalList
PositionalList.java:81: error: cannot find symbol
Position addAfter(Position p, E e)
^
symbol: class Position
location: interface PositionalList
PositionalList.java:81: error: cannot find symbol
Position addAfter(Position p, E e)
^
symbol: class E
location: interface PositionalList
PositionalList.java:81: error: cannot find symbol
Position addAfter(Position p, E e)
^
symbol: class Position
location: interface PositionalList
PositionalList.java:92: error: cannot find symbol
E set(Position p, E e) throws IllegalArgumentException;
^
symbol: class Position
location: interface PositionalList
PositionalList.java:92: error: cannot find symbol
E set(Position p, E e) throws IllegalArgumentException;
^
symbol: class E
location: interface PositionalList
PositionalList.java:92: error: cannot find symbol
E set(Position p, E e) throws IllegalArgumentException;
^
symbol: class E
location: interface PositionalList
PositionalList.java:102: error: cannot find symbol
E remove(Position p) throws IllegalArgumentException;
^
symbol: class Position
location: interface PositionalList
PositionalList.java:102: error: cannot find symbol
E remove(Position p) throws IllegalArgumentException;
^
symbol: class E
location: interface PositionalList
Main.java:27: error: cannot find symbol
head = new Node();
^
symbol: class Node
location: class DoublyLinkedList
Main.java:28: error: cannot find symbol
tail = new Node();
^
symbol: class Node
location: class DoublyLinkedList
Main.java:38: error: cannot find symbol
return size;
^
symbol: variable size
location: class DoublyLinkedList
49 errors

OUTPUT:-


Related Solutions

java.. please dont change the format and give me an output sample! user need to input...
java.. please dont change the format and give me an output sample! user need to input k. public class Josephus {    /**    * All persons sit in a circle. When we go around the circle, initially starting    * from the first person, then the second person, then the third...    * we count 1,2,3,.., k-1. The next person, that is the k-th person is out.    * Then we restart the counting from the next person, go...
This a public health question, please be detail in the reponse and dont copy/ paste google...
This a public health question, please be detail in the reponse and dont copy/ paste google responses What are the purposes of an evaluation effort? 2. Who benefits from an evaluation? Who is it for? 3. How might the evaluation differ based on stakeholder needs? How might the evaluation differ based on the proposed “use”? 4. How might the format of an evaluation affect community members? 5. What are the most important outcomes to measure in an evaluation?
Please show work. A. For single reactant: observe the change in rate for a change in...
Please show work. A. For single reactant: observe the change in rate for a change in initial reactantconcentration. Reaction 1 Reaction 2 Reaction 3 [A] (M) Initial Rate (M/s) [C] (M) Initial Rate (M/s) [K] (M) Initial Rate (M/s) 0.10 0.015 0.10 0.015 0.10 0.015 0.20 0.030 0.20 0.060 0.30 0.135 0.40 0.060 0.40 0.240 0.90 1.215 The table above shows three independent reactions (not related to each other). What are the rate laws for each of thesereactions? B. For...
Trace the sample run provided for Search2D class .................................................................. public class Search2D {     /**     ...
Trace the sample run provided for Search2D class .................................................................. public class Search2D {     /**      * Searches for the desiredItem in a rectangular matrix[][] where      * elements are sorted within each row and within each column      * If the element is found, prints its position,      * otherwise prints "not found"      *      * @author YOUR NAME      * @version 10/20/2020      *      */     private void search(int[][] matrix, int desiredItem)     {         //...
Trace the sample run provided for Search2D class .................................................................. public class Search2D {     /**      * Searches...
Trace the sample run provided for Search2D class .................................................................. public class Search2D {     /**      * Searches for the desiredItem in a rectangular matrix[][] where      * elements are sorted within each row and within each column      * If the element is found, prints its position,      * otherwise prints "not found"      *      * @author  YOUR NAME      * @version 10/20/2020      *      */     private void search(int[][] matrix, int desiredItem)     {         // TODO Project 4         // TODO must implement with one loop only         System.out.println("Searching for "...
Please convert this java program to a program with methods please. import java.io.*; import java.util.*; public...
Please convert this java program to a program with methods please. import java.io.*; import java.util.*; public class Number{ public static void main(String[] args) {    Scanner scan = new Scanner(System.in); System.out.println("Enter 20 integers ranging from -999 to 999 : "); //print statement int[] array = new int[20]; //array of size 20 for(int i=0;i<20;i++){ array[i] = scan.nextInt(); //user input if(array[i]<-999 || array[i]>999){ //check if value is inside the range System.out.println("Please enter a number between -999 to 999"); i--; } } //...
1)In the short run, show graphical and explain how does the Fed change the nominal interest...
1)In the short run, show graphical and explain how does the Fed change the nominal interest rate? 2) In the long Run Show graphical and explain how does the Fed increase or decrease in the quantity of money affects the value of money
derive all groups of order 12 using sylow theorems. please dont use any generalizations show all...
derive all groups of order 12 using sylow theorems. please dont use any generalizations show all work and theorems used. all 5 of them
Greetings, Please assist with summarizing one of the Public Health Impacts of Climate Change.
Greetings, Please assist with summarizing one of the Public Health Impacts of Climate Change.
show how the short-run model would change with a decrease in domestic money supply, specifically noting...
show how the short-run model would change with a decrease in domestic money supply, specifically noting the impact on domestic interest and the price level
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT