Dynamic Array Queue Code/Assignment1.java Dynamic Array Queue Code/Assignment1.java public class Assignment1 { public static void main(String[] args) { DynamicArrayQueue fileLines; InputReader ir;...

1 answer below »
Attached are the the java files and instructions for the project


Dynamic Array Queue Code/Assignment1.java Dynamic Array Queue Code/Assignment1.java public class Assignment1 {   public static void main(String[] args)   {     DynamicArrayQueue fileLines;     InputReader ir;     String filename;     filename = args[0];     ir = new InputReader(filename);     fileLines = ir.readAndReturnFileLines();     while (!fileLines.isEmpty())     {       System.out.println(fileLines.dequeue());     }   } } Dynamic Array Queue Code/DynamicArrayQueue.java Dynamic Array Queue Code/DynamicArrayQueue.java public class DynamicArrayQueue implements Queue {   public static final int DEFAULT_CAPACITY = 2;   int front;   int theSize;   AnyType[] data;   public DynamicArrayQueue()   {     this(DEFAULT_CAPACITY);   }   public DynamicArrayQueue(int capacity)   {     front = 0;     theSize = 0;     data = (AnyType[]) new Object[capacity];   }   public int size()   {     return theSize;   }   public boolean isEmpty()   {     return (size() == 0);   }   protected void resize(int newCapacity)   {   }   public void enqueue(AnyType newValue)   {   }   public AnyType first() throws IllegalStateException   {   }   public AnyType dequeue() throws IllegalStateException   {   } } Dynamic Array Queue Code/InputReader.java Dynamic Array Queue Code/InputReader.java import java.io.BufferedReader; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; public class InputReader {   BufferedReader br;   public InputReader(String filename)   {     try     {       FileInputStream fstream = new FileInputStream(filename);       br = new BufferedReader(new InputStreamReader(fstream));     }     catch (IOException e)     {       System.out.println(e);     }   }   public DynamicArrayQueue readAndReturnFileLines()   {   } } Dynamic Array Queue Code/Queue.java Dynamic Array Queue Code/Queue.java public interface Queue {   int size();   boolean isEmpty();   void enqueue(AnyType newValue);   AnyType first();   AnyType dequeue(); } Page 1 of 2 DynamicArrayQueue Assignment Assignment objective: Implement a dynamic array queue data structure. Design: 1. Download the files Assignment1.java, DynamicArrayQueue.java, InputReader.java, and Queue.java provided along with this assignment in Blackboard and include them in your project. 2. The file Queue.java contains the queue interface. You cannot modify any of the code in this file. 3. The file Assignment1.java is the driver code for the assignment. You cannot and do not need to modify any of the code in this file. The main function receives, via the command line argument, the name of a text file containing lines of text. The main method creates an InputReader object and then calls the readAndReturnFileLines method of the InputReader object. The readAndReturnFileLines method returns a DynamicArrayQueue containing the lines of text from the text file. The main method then dequeues each line of text from the DynamicArrayQueue and prints the line of text on a separate line. 4. The file InputReader.java is the class which reads the lines of text from the text file. You cannot change any of the code that is already in this file. You will write the code for the readAndReturnFileLines method. The method first creates a DynamicArrayQueue whose values are strings. Then, the method reads each line from the text file and enqueues it into the DynamicArrayQueue. Finally, the method returns that DynamicArrayQueue. 5. The file DynamicArrayQueue.java implements a queue using an array as storage where the queue’s array grows and shrinks in size as discussed in class. You cannot change any of the code that is already in this file. You will write the code for the resize, enqueue, first, and dequeue methods. 6. You can copy and use the code of the resize method from the DynamicArrayList class for the resize method of the DynamicArrayQueue class. But, to implement the resize method for the DynamicArrayQueue class, you must modify it because in the array implementation of a queue the values in the queue can wrap around from the end of the array data to the beginning of the array data. For example, copying the values of the queue from the array data to the array temp is done as follows: the first value (at the front) in the queue copies to temp[0], the second value in the queue copies to temp[1], the third value in the queue copies to temp[2], and so forth until the last value in the queue is copied into the appropriate position in the array temp. 7. The command to launch your program, assuming test.txt is the name of the text file, is: java Assignment1 test.txt Page 2 of 2 8. Do NOT use packages in your program. If you see the keyword package on the top line of any of your .java files then you created a package. 9. Do NOT use any graphical user interface code in your program! 10. Do NOT type any comments in your program. If you do a good job of programming it will be easy for me to determine the task of your code.
Answered 5 days AfterNov 09, 2021

Answer To: Dynamic Array Queue Code/Assignment1.java Dynamic Array Queue Code/Assignment1.java...

Kshitij answered on Nov 12 2021
124 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here