CSC 132 Fall 2000

Lab 6

Due: end of today's lab, 19 October 2000

15 points

"Palindrome Revisited"

 

Check for palindromes (lab 4) again, this time using java.util.Stack. instead of a CharList to store the characters. See Sun's java.util.Stack documentation at http://java.sun.com/j2se/1.3/docs/api/java/util/Stack.html.

You will need files PalsApplet.java and PalsApplet.html from the eccentric download folder for Lab 6. PalsApplet.java is basically a copy of Lab 4's PalApplet.java with the debug code commented out. The debug code for testing "equals" has been removed because it is irrelevant to this assignment.

Your assignment: modify PalsApplet.java, specifically the actionPerformed() method, to use the Java Stack class instead of your CharList class to store the characters and test for palindrome-ness. Note that this method contains the logic to ignore spaces and to convert all characters to lower case before storing them. Please use this. You will need to devise a strategy for determining whether the input string is a palindrome, using only Stack objects. Hint: this will require a total of three Stacks. Then output the result to the feedback textarea.

Bonus: For 5 extra points, implement the two debugging outputs that are commented out. The first one outputs the original stack contents, and the second outputs the reverse (which will come from a different stack). Hint: Stack inherits iterator capability from AbstractList.

Submit the modified PalsApplet.java file to your eccentric upload folder. Do not make any changes outside the actionPerformed() method.

Document your code judiciously.


[ Assignments | CSC 132 | Peter Sanderson | Computer Science | SMSU ]


Last reviewed: 18 October 2000

Peter Sanderson ( PeteSanderson@smsu.edu )