need help to create an array of CDs, where the data comes from a text file, and then sorts the array content by artist name, then title,releaseyear,length in ascending order of artists name.(2 classes main and Cd ) When sorting is done is written a new fill to disk, with the sorted data. without using arraylists,linkedlist treemap.

It must be look like
CD cdArray = new CD [number of records].
Note that this only creates the array, not the discs. The discs are created as in inside an iteration
Sorting doing by writing about sort method in the notes so that it works with arrays of type CD instead of String or double.
To create CDs disk must read the contents of the previously scanned the array of text lines. It does so with a iterationssats, enumeration of all elements. Each line of text is then divided into "space", see the method String [] split (String) in the String class. Note the return type String [], it returns an array of type String. Declaring such an array to receive the return value. This array then has a length (length attributes) that makes it possible to many elements are in the text line
Printing to file is best done by following the example print and customize it so that it prints the sorted array CD.

CD class look like :
CD(String artist, String title, String genre, String label, int releaseYear, int noOfSongs, double length)


Load file (.txt)
Create array of CDs -----not using arraylist linklist
Sort CDs
Writing the sorted array to a file (.txt)

Recommended Answers

All 2 Replies

will do that for you.
just make sure your data type knows how you want it to be sorted.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.