ScholarMatic | 24/7 Homework Help

ScholarMatic Will Help You Write Your Essays and Term Papers

Answered » You can buy a ready-made answer or pick a professional tutor to order an original one.

Code a new method to be exported from ArrayStringLog called howMany() , with the following signature:

by | Nov 28, 2023 | computer science

Code a new method to be exported from ArrayStringLog called howMany() , with the following signature:

public int howMany (String element)

The method returns a integer value indicating how many times element occurs in the log

****Here is the ArrayStringLog:

public class ArrayStringLog implements StringLogInterface

{

protected String name; // name of this StringLog

protected String[] log; // array that holds strings

protected int lastIndex = -1; // index of last string in array

public ArrayStringLog(String name, int maxSize)

// Precondition: maxSize > 0

//

// Instantiates and returns a reference to an empty ArrayStringLog

// object with name “name” and room for maxSize strings.

{

log = new String[maxSize];

this.name = name;

}

public ArrayStringLog(String name)

// Instantiates and returns a reference to an empty ArrayStringLog

// object with name “name” and room for 100 strings.

{

log = new String[100];

this.name = name;

}

public void insert(String element)

// Precondition: This StringLog is not full.

//

// Places element into this StringLog.

{

lastIndex++;

log[lastIndex] = element;

}

public boolean isFull()

// Returns true if this StringLog is full, otherwise returns false.

{

if (lastIndex == (log.length – 1))

return true;

else

return false;

}

public int size()

// Returns the number of Strings in this StringLog.

{

return (lastIndex + 1);

}

public boolean contains(String element)

// Returns true if element is in this StringLog,

// otherwise returns false.

// Ignores case differences when doing string comparison.

{

int location = 0;

while (location <= lastIndex)

{

if (element.equalsIgnoreCase(log[location])) // if they match

return true;

else

location++;

}

return false;

}

ScholarMatic: Explanation & Answer

Your ready answer from a verified tutor is just a click away for as little as $14.99


  

Click Order Now to get 100% Original Answer Customized to your instructions!

HOME TO CERTIFIED WRITERS

Why Place An Order With Us?

  • Certified Editors
  • 24/7 Customer Support
  • Profesional Research
  • Easy to Use System Interface
  • Student Friendly Pricing

Have a similar question?

PLAGIRAISM FREE PAPERS

All papers we provide are well-researched, properly formatted and cited.

TOP QUALITY

All papers we provide are well-researched, properly formatted and cited.

HIGHLY SECURED

All papers we provide are well-researched, properly formatted and cited.

ScholarMatic: Get Started

Assignment Writing Service

Feel safe and secure when placing an order on our portal!
Fruitful cooperation begins with solid guarantees, and we are professional enough to promise perfect results. Let’s get it started!