Program in Java Lab 4 Directions (Stacks) Program #1 1. Show the ArrayStackADT interface 2. Create the ArrayStackDataStrucClass with the following methods: default constructor, overloaded
Program in Java
Lab 4 Directions (Stacks) Program #1 1. Show the ArrayStackADT interface
2. Create the ArrayStackDataStrucClass with the following methods: default constructor, overloaded constructor, copy constructor, initializeStack, isEmptyStack, isFullStack, push, peek, void pop 3. Create the PrimeFactorizationDemoClass: instantiate an ArrayStackDataStrucClass object with 50 elements. Use a try- catch block in the main( ) using pushes/pops. 4. Exception classes: StackException, StackUnderflowException, StackOverflowException 5. Show the 4 outputs for the following: 3,960 1,234 222,222 13,780
Program #2 1. Show the ListStackADT interface 2. Create a ListStackDataStrucClass with the following methods: default constructor, overloaded constructor, copy constructor, getTop, setTop, isEmpty, ifEmpty (if empty throw the exception), push, peek, pop, toString. 3. Create a private inner class of ListStack called StackNode with the following methods: default constructor, overloaded constructor, copy constructor, getValue, getNext, setValue, setNext 4. Create a BaseConverter class (non-generic) with the following methods: default constructor, inputPrompt, convert [converts a BaseNumber to a converted String], convertAll [instantiate a String object] , toString, processAndPrint
2 5. Create a private inner class BaseNumber. The inner class has the following methods: default constructor, overloaded constructor, getNumber, getBase, setNumber, setBase. [Make your private instance variables in the inner class Long type]. 6. Create a BaseConverterDemo class that only has 2 statements: Create a BaseConverter object and then have it invoke processAndPrint. 7. Exception classes: StackException, EmptyStackException, FullStackException
Program #3 1, Show the LinkedtStackADT interface 2. Create a LinkedStackDS with the following methods: default constructor, overloaded constructor, copy constructor, isEmptyStack, push, peek, pop 3. Create a private inner StackNode class with the following methods: default constructor, overloaded constructor, toString 3. Exception classes: StackException, StackUnderflowException, StackOverflowException 4. Create a PalindromeDemo class that instantiates a LinkedStackDS object. Execute a do-while loop that asks the user using dialog boxes to Input a String for Palindrome Test: Use the replaceAll method to remove all blanks and special characters from testStr. Output whether or not it is a palindrome in a dialog box. [Use the 5 inputs given on the other handout sheet for testing.]