Question
20. Code a class that implements the Sorted Array structure, and write a progressively developed driver program that verifies the functionality of all of its
20. Code a class that implements the Sorted Array structure, and write a progressively developed driver program that verifies the functionality of all of its methods. Assume that it is to store a data set whose nodes are described in Exercise 19. Include error checking in the code of the basic operation methods, a constructor to permit the client to specify the maximum size of the data set, and a method to display the contents of entire data set in sorted order. Here is the code from exercise 19 that I have:
package studentlistings; import javax.swing.JOptionPane;
public class StudentListings { private String name; private String number; private String gpa; public StudentListings() { name = ""; number = ""; gpa = ""; } public String toString() { return("Name is " + name + " Number is " + number + " GPA is " + gpa ); } public StudentListings deepCopy() { StudentListings clone = new StudentListings(); return clone; } public int compareTo(String targetKey) { return (name.compareTo(targetKey)); } public void input() { name = JOptionPane.showInputDialog("Please enter the name: "); number = JOptionPane.showInputDialog("Please enter a number"); gpa = JOptionPane.showInputDialog("Please enter a GPA:"); } public static void main(String[] args) { StudentListings studentList = new StudentListings(); studentList.input(); System.out.println(studentList.toString()); studentList.deepCopy(); System.out.println("This name has been successfully added to the database"); } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started