Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a class that can be used to test data structure - similar to the StudentA.java example found shown below: The following are requirements for

Create a class that can be used to test data structure - similar to the StudentA.java example found shown below:

The following are requirements for this homework: Unique index integer fields Use at least 5 other fields of various, including at least one of each of String, int and double types. o assume that the String's have no spaces within them Write a method that will create an array of N random instances of this class, where N is an integer parameter to this method Provide a toString method that will format an instance of this class nicely Provide appropriate constructors Write methods that will write and read text files of this class o to make this easy, assume that the first line of the file is the number of elements in the file o make the file one line per entry o use spaces as field delimiters in the files o use the toString method of the class to write to the file Provide a good GUI interface to control and test this class, at a minimum: o use buttons to control the functions available o use JFileChoose for selecting input and output files o use a JTextArea and JScrollPane to create a scrolling text area for output o the window should resize nicely - use BorderLayout with the text area in the center

image text in transcribed

image text in transcribed

StudentA.java import java.util.Scanner; import java.util.ArrayList; lass StudentA lements Comparable firstName s = new ArrayList (); static ArrayList lastName s new ArrayList (); static SORTBY sortBy- SORTBY. LAST; static int nextU1D = 1; String first, last; double gpa - 0 int credits = 0; int uid try java.util.Scanner scFirst-new java.util.Scanner (new java.util. Scanner scLast = new java.util. Scanner (new while (scFirst.hasNext ()) firstNames.add (scFirst.next )) java.io.File("firstNames.txt")); java.io.File ("lastNames.txt")); while scLast.hasNext ()) lastNames.add ( scLast.next )) catch (java.io.FileNotFoundException e) System.out.println (e); ) // end try catch // end static intializer //end static intializer enum SORTBY (LAST, FIRST, CREDITS, GPA) uden ring S this (new Scanner (st) ) uden anner s ul first last credits gpa nextUID++; sc. next () ; sc. next ( ) ; sc. next Int () ; sc. next Double ( ) ; = = // end Scanner constructor public StudentA uid-nextUID++; // no parameter constructor nt compareld uden switch (sortBy) [ case LAST: return last.compareTo (x.last)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Database Relational Model A Retrospective Review And Analysis

Authors: C. J. Date

1st Edition

0201612941, 978-0201612943

More Books

Students also viewed these Databases questions

Question

Discuss how Internet advertising is written.

Answered: 1 week ago