Question: Consider an ADT called StringSeries, which allows access to Strings in sequential order. String Series has a cursor which points to some String in the


Consider an ADT called StringSeries, which allows access to Strings in sequential order. String Series has a cursor which points to some String in the Series. When a Series is instantiated, the cursor is set to the first String in the series. Put your work in a package named hw2. Series supports the following public operations: void add(String s): adds the String s to the end of the series String get(); return a reference to the String that the cursor currently points to void advance(): Advance the cursor to the String following the one it currently points to, or throw an Exception if the cursor already points to the last String (just use Exception with the error message "no element found"); void retreat(): Move the cursor back one String in the StringSeries, or throw an exception if it already points to the first String int size(): Return the number of Strings in the String Series For example, suppose we create a new String Series. Here is sequence of operations we might run with their return values: size(): 0 add("John"); void add("Paul"); void add("George"); void add("Ringo"); void size(); 4 get(); "John" retreat(); exception advance(): void advance(); void get(); "John" retreat(); exception advance(); void advance(); void get(): "George advance(); void get(); "Ringo" advance(); exception retreat(); void get(); "George" Part A: 25 points Create the Java interface String Series, which includes all the methods shown above Part B: 50 points Create the class ArrayString Series, which implements String Series using an underlying array of 10 Strings. In other words, ArrayStringSeries has a private varaay of ten Strings. Note that ArrayString Series will need a constructor that creates an array of 10 Strings. you will need to keep track of how many Strings are in the String Series at any time, since it may be less than 10 . this implementation will not be able to hold a String Series with more than 10 Strings Part C: 25 points Write a driver class that creates an ArrayString Series and runs the operations shown in the example above, printing the results. Also turn in a text file with file name extension .txt containing the output from a run of your driver. Make sure the return values are correct
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
