Question: Implement the method reverseString in Lab 5 Tester according to the documentation provided. Make sure to write additional tests to ensure your implementation is correct.

Implement the method reverseString in Lab5Tester according to the documentation provided.
Make sure to write additional tests to ensure your implementation is correct. You MUST use a stack
in your implementation
public class Lab5Tester {
private static int testPassCount =0;
private static int testCount =0;
public static void main (String[] args){
try {
testBasicStack();
testStackUseFunctions();
// testQueue();
} catch (Exception e){
System.out.println("Your code threw an Exception.");
System.out.println("Perhaps a stack trace will help:");
e.printStackTrace(System.out);
}
System.out.println("Passed "+ testPassCount +"/"+ testCount +" tests");
}
/*
* Purpose: reverses given string following this algorithm
*- pushes each character in str onto a new stack
*- creates a new empty result String
*- pops each character off the Stack adding it to the result String
*- returns the result String
* Parameters: String str - the String to reverse
* Returns: String - the reversed result String
*/
public static String reverseString(String str){
Stack stk = new StackArrayBased();
String result ="";
// TODO: complete the implementation
return result;
}
/*
* Purpose: determines whether every '(' has a matching ')'
* found later in the string. Any ')' that does not
* have a preceding '(' means the brackets do not match
* Parameters: String str - the String to check for a bracket match
* Returns: boolean - true if brackets are matched, false otherwise
*/
public static boolean doBracketsMatch(String str){
Stack stk = new StackArrayBased();
// TODO: complete the implementation
return false; // so it compiles
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!