I308 C307 Data/Information Representation

I308 C307 Lab 3

Due Date: Monday, February 14, 2022.

In this lab, we will create a set of Java classes for manipulating a stack derived from a linked list containing characters.

Ex. 1. The Stack Class

a. Inherited Classes

In Eclipse or Netbeans, create a project called hw5. In this project, create a class called Node in a package called hw5. Copy the code from homework 4 (lab 2) for the Node class into this class, but change the type of the datum attribute to char.

The same way, create a class called List and copy the code from homework 4 (lab 2) into it, except for all the methods using iterators. Change anything that requires an integer (matching the datum) into char.

b. Stack Class

Add a new class to the project called Stack, declared as extending the class List. You can use the lecture slides for the code in this class. Declare the functions push, pop, the constructor, clear, isEmpty, size (just return the attribute size), as well as print.

c. Test.

Add another class called Interface containing the main function. Add a static function in this class called testStack where you declare a stack, push a few letters into it (use single quotes), print the stack, then perform some pop operations and output the result. Call this function in the main to test it. Run the program to make sure it works fine.

This program will be continued in the homework.

Lab Submission

Upload all the .java files to Canvas - Assignments - Homework 5 after you complete the homework.