Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Using the ArrayStringLog class developed in Week 0 1 Lab as a starting point, implement an UnbndStringLog class that uses an ArrayList as the underlying
Using the ArrayStringLog class developed in Week Lab as a starting point, implement an UnbndStringLog class that uses an ArrayList as the underlying structure. Include all methods from Lab
package stringLog;
public interface StringLogInterface
void insertString element;
boolean containsString element;
void removeString Element;
int Size;
void clear;
public boolean isEmpty;
public boolean isFull;
String toString;
package stringLog;
public class ArrayStringLog implements StringLogInterface
protected String list null;
protected int count ;
protected int index ;
public ArrayStringLog
list new String;
public ArrayStringLogint count
list new Stringcount;
public int howManyString element
int occurrences ;
forint i ; i count; i
iflistiequalsIgnoreCaseelement
occurrences;
return occurrences;
public boolean uniqueInsertString element
ifcontainselement
insertelement;
return true;
return false;
public String smallest
ifcount
return null;
String smallest list;
forint i ; i count; i
iflisticompareTosmallest
smallest listi;
return smallest;
public int removeAllString element
int removedCount ;
forint i ; i count; i
iflistiequalsIgnoreCaseelement
removeelement;
removedCount;
i;
return removedCount;
@Override
public void insertString element
ifcount list.length
listcount element;
count;
@Override
public boolean containsString element
index ;
forint i ; i count && index ; i
iflistiequalsIgnoreCaseelement
index i;
return index ;
@Override
public void removeString element
ifcontainselement
count;
listindex listcount;
listcount null;
@Override
public int Size
return count;
@Override
public boolean isEmpty
return count ;
@Override
public boolean isFull
return count list.length;
@Override
public void clear
forint i ; i count; i
listi null;
count ;
public String toString
String result "String Log:
;
int num ;
forint i ; i count; i
result num listi
;
num;
return result;
package stringLog;
import stringLog.ArrayStringLog;
import stringLog.StringLogInterface;
public class StringLogTest
public static void mainString args
StringLogInterface log new ArrayStringLog;
System.out.printlnEmpty string log;
System.out.println Log size; logSize;
System.out.printlnlog;
loginsertAnne;
loginsertBob;
loginsertCharlie;
loginsertDiane;
System.out.printlnLog size: logSize;
System.out.printlnThe gang's all here";
System.out.printlnlog;
logclear;
System.out.printlnEmpty String Log";
System.out.printlnLog size: logSize;
System.out.printlnlog;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started