Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using the code below Design and code a new method to be exported from LinkedStri

ID: 3623665 • Letter: U

Question

Using the code below

Design and code a new method to be exported from LinkedStringLog called isEmpty, with the following signature:

public boolean isEmpty()

The method returns ture if the StringLog is empty and false otherwise.


public class LinkedStringLog implements StringLogInterface
{
protected LLStringNode log; // reference to first node of linked
// list that holds the StringLog strings
protected String name; // name of this StringLog

public LinkedStringLog(String name)
// Instantiates and returns a reference to an empty StringLog object
// with name "name".
{
log = null;
this.name = name;
}

public void insert(String element)
// Precondition: This StringLog is not full.
//
// Places element into this StringLog.
{
LLStringNode newNode = new LLStringNode(element);
newNode.setLink(log);
log = newNode;
}

public boolean isFull()
// Returns true if this StringLog is full, false otherwise.
{
return false;
}

public int size()
// Returns the number of Strings in this StringLog.
{
int count = 0;
LLStringNode node;
node = log;
while (node != null)
{
count++;
node = node.getLink();
}
return count;
}

public boolean contains(String element)
// Returns true if element is in this StringLog,
// otherwise returns false.
// Ignores case difference when doing string comparison.
{
LLStringNode node;
node = log;
boolean found = false;
boolean moreToSearch;
moreToSearch = (node != null);

while (moreToSearch && !found)
{
if (element.equalsIgnoreCase(node.getInfo())) // if they match
found = true;
else
{
node = node.getLink();
moreToSearch = (node != null);
}
}

return found;
}

public void clear()
// Makes this StringLog empty.
{
log = null;
}

public String getName()
// Returns the name of this StringLog.
{
return name;
}

public String toString()
// Returns a nicely formatted string representing this StringLog.
{
String logString = "Log: " + name + " ";
LLStringNode node;
node = log;
int count = 0;

while (node != null)
{
count++;
logString = logString + count + ". " + node.getInfo() + " ";
node = node.getLink();
}

return logString;
}
}

Explanation / Answer

Dear.. public class LinkedStringLog implements StringLogInterface { protected LLStringNode log; protected String name;     public LinkedStringLog(String name) {     log = null;     this.name = name; } public LinkedStringLog(String name) {     log = null;     this.name = name; } public int howMany(String element) // this method returns an int value how many times it occurs in StringLog {     int elemtCount = 0;              LLStringNode node;              node = log;                           while (node != null)              {                if (element.equalsIgnoreCase(node.getInfo()))                         {                          elemtCount ++;                          node = node.getLink();                         }                         else                         {                          node = node.getLink();                         }              }              return eleCount; }
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote