Answer To: https://github.com/cs1302uga/cs1302-phased-list2This is the website for the assignment details....
Sonu answered on Mar 28 2021
cs1302/.classpath
cs1302/.project
cs1302
org.eclipse.jdt.core.javabuilder
org.eclipse.jdt.core.javanature
cs1302/ArrayStringList.class
public synchronized class ArrayStringList extends BaseStringList {
private String[] items;
private int storage;
public void ArrayStringList();
public void ArrayStringList(FancyStringList);
public void clear();
public String get(int);
public String remove(int);
public StringList slice(int, int);
public boolean add(int, String);
private void increseStorage();
private void updateFromBase();
public FancyStringList slice(int, int, int);
public FancyStringList reverse();
}
cs1302/ArrayStringList.java
cs1302/ArrayStringList.java
//package src;
//import cs1302.adt.StringList;
public class ArrayStringList extends BaseStringList{
private String[] items;
private int storage;
// default constructor
public ArrayStringList(){
super();
items = new String[5];
storage = 5;
}
// deep copy constructor
public ArrayStringList(FancyStringList list){
clear();
items = new String[list.size()];
storage = list.size();
for(int i = 0;i append(list.get(i));
}
}
@Override
public void clear() {
baseitems = "";
size = 0;
items = new String[0];
}
@Override
public String get(int index) {
updateFromBase();
if(index < 0 && index >= size) {
throw new IndexOutOfBoundsException();
}
return items[index];
}
@Override
public String remove(int index) {
updateFromBase();
if(index < 0 && index >= size) {
throw new IndexOutOfBoundsException();
}
String res = items[index];
for(int i = index;i items[i] = items[i+1];
}
int c = 0;
String a = "";
String b = "";
for(int i = 0;i if(baseitems.charAt(i) == ',') {
c++;
}
if(c < index) a += baseitems.charAt(i);
if(c > index) b += baseitems.charAt(i);
}
baseitems = a+b;
size--;
return res;
}
@Override
public StringList slice(int start, int stop) {
updateFromBase();
if((start < 0 || start >= size) || (stop < 0 || stop >= size) || start > stop) {
throw new IndexOutOfBoundsException();
}
StringList res = new ArrayStringList();
for(int i = start;i res.add(i-start,items[i]);
}
return res;
}
@Override
public boolean add(int index, String item) {
if(index < 0 && index > size()) {
throw new IndexOutOfBoundsException();
}
if(item == null) {
throw new NullPointerException();
}
if(item == "") {
throw new IllegalArgumentException();
}
if(size() == storage) increseStorage();
String t = item;
String prev = item;
for(int i = index;i t = items[index];
items[index] = prev;
prev = t;
}
items[size] = prev;
int c = 0;
String a = "";
String b = "";
for(int i = 0;i if(baseitems.charAt(i) == ',') {
c++;
}
if(c < index) a += baseitems.charAt(i);
if(c >= index) b += baseitems.charAt(i);
}
if(a.length() > 0 && b.length() > 0)
baseitems = a +','+ item + b;
else
baseitems = item + ',' + b;
//System.out.println(baseitems);
size++;
return true;
}
// function to increase the size of array
private void increseStorage() {
String[] temp = items;
storage = storage + storage/4;
items = new String[storage];
for(int i = 0;i items[i] = temp[i];
}
}
//The string from basestringlist is being converted in array of strings
private void updateFromBase() {
String prev = "";
int k = 0;
if(size() >= storage)
increseStorage();
for(int i = 0;i if(baseitems.charAt(i) == ','){
if(prev.length() > 0) items[k++] = prev;
prev = "";
}
else
prev += baseitems.charAt(i) ;
}
}
@Override
public FancyStringList slice(int start, int stop, int step) {
if(start < 0 || stop > size() || step < 1) {
throw new IndexOutOfBoundsException();
}
FancyStringList fsl = new ArrayStringList();
for(int i = 0;i fsl.append(get(i));
}
return fsl;
}
@Override
public FancyStringList reverse() {
int i = 0;
FancyStringList fsl = new ArrayStringList();
while(i < size()) {
fsl.prepend(get(i));
i++;
}
return fsl;
}
}
cs1302/BaseStringList.class
public abstract synchronized class BaseStringList implements FancyStringList {
protected int size;
protected String baseitems;
public void BaseStringList();
public boolean append(String);
public boolean append(StringList);
public boolean contains(int, String);
public boolean prepend(StringList);
public int indexOf(int, String);
public boolean add(int, StringList);
public boolean isEmpty();
public String makeString(String, String, String);
public boolean prepend(String);
public int size();
public String toString();
public abstract void clear();
public abstract String get(int);
public abstract String remove(int);
public abstract StringList slice(int, int);
public abstract boolean add(int, String);
public abstract FancyStringList reverse();
public abstract FancyStringList slice(int, int,...