Question: Revise the set class (Programming Project 5 on page 169) so that it stores the items in a linked list instead of in an array.

Revise the set class (Programming Project 5 on page 169) so that it stores the items in a linked list instead of in an array.


Data from Project 5

Using Appendix I as a guide, implement an applet for interactive testing of the sequence class from the previous project.


Appendix I

It’s useful to have a small interactive test program to help you test class methods. Such a program can be written as a Java applet, which is a Java program written in a special format to have a graphical user interface. The graphical user interface is also called a GUI (pronounced “gooey”), and it allows a user to interact with a program by clicking the mouse, typing information into boxes, and performing other familiar actions. With a Java applet, GUIs are easy to create, even if you’ve never run into such goo before.

This appendix, which shows one simple pattern for developing such applets, is online at: http://www.cs.colorado.edu/~main/javasupp/applets.pdf.


Data from Previous Project

Implement the sequence class from Section 3.3. You may wish to provide some additional useful methods, such as:

(1) A method to add a new element at the front of the sequence; 

(2) A method to remove the element at the front of the sequence; 

(3) A method to add a new element at the end of the sequence; 

(4) A method that makes the last element of the sequence become the current element; 

(5) A method that returns the ith element of the sequence (starting with the 0th at the front);

(6) A method that makes the ith element become the current element.

Step by Step Solution

3.55 Rating (152 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

public class Set private Node head private int size private static class Node private E element priv... View full answer

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 Data Structures and Other Objects Using Java Questions!