Docsity

Data Structures: Sortable Table - Homework 6 | CS 251L, Assignments of Computer Science

Toggle sidebar
bg1
CS 251L Homework 6
Data Structures: Sortable Table
Assigned: November 26, 2008
Due: December 10, 2008 @ 12:00pm (submitted before class starts)
Submission Method: Email solution to [email protected] by due date.
Please identify your submission in the email subject header as being homework 6. Attach the source file(s) containing the
modified application, your comparison classes, and the modified Song class. You may attach multiple source files separately
or archive them using a mainstream archiver (.zip, .sit, .tar.gz, etc.). If you are sending loose files, please create a proper email
attachment rather than copy/pasting one after the other. If you send an unreadable file or archive, the instructor will generally
notify you that you need to resubmit it, but the homework is not considered turned in until the instructor gets a readable file.
To get started, download Homework6.java from the class website. This class contains a simple application for displaying a
sorted list of Songs that can be reordered by the user by clicking on the table headers. A method has been stubbed out to
perform the actual ordering:
private Collection<Song> sort(Collection<Song> unsorted, String field);
When the user clicks on a table header, a MouseListener is informed and calls this method, passing it the current
collection of songs and a desired sort field. The value of field will be either โ€œtitleโ€, โ€œartistโ€, โ€œcategoryโ€, or โ€œyearโ€
depending on which of the Song fields the collection should be ordered by. This method should make use of Comparable/
Comparator objects to return a sorted collection. The application will then update the table with the objects in the new
ordering.
The application contains an example of using the JTable class to display data. This GUI component is paired with a table
model class which performs transformations between the {row, column} lookups used by tables and the accessor calls used
on data model objects. It also supplies information like row and column counts and column header names to the table.
The table is enclosed in a JScrollPane, which displays scroll bars as necessary if the table contents should exceed the size
of the window.
pf2

Partial preview of the text

Download Data Structures: Sortable Table - Homework 6 | CS 251L and more Assignments Computer Science in PDF only on Docsity!

CS 251L

Homework 6

Data Structures: Sortable Table

Assigned

: November 26, 2008

Due

: December 10, 2008 @ 12:00pm (submitted before class starts)

Submission Method

: Email solution to [email protected] by due date.

Please identify your submission in the email subject header as being homework 6. Attach the source

(^) fi le(s) containing the

modi

fi ed application, your comparison classes, and the modi

fi ed

Song

(^) class. You may attach multiple source

(^) fi les separately

or archive them using a mainstream archiver (.zip, .sit, .tar.gz, etc.). If you are sending loose

(^) fi les, please create a proper email

attachment rather than copy/pasting one after the other. If you send an unreadable

fi le or archive, the instructor will generally

notify you that you need to resubmit it, but the homework is not considered turned in until the instructor gets a readable

(^) fi le.

To get started, download

(^) Homework6.java

from the class website. This class contains a simple application for displaying a

sorted list of

Song

s that can be reordered by the user by clicking on the table headers. A method has been stubbed out to

privateperform the actual ordering:

Collection sort(Collection unsorted, String field);

When the user clicks on a table header, a

(^) MouseListener

is informed and calls this method, passing it the current

collection of songs and a desired sort

fi eld. The value of

(^) fi eld will be either โ€œ

title

artist

category

โ€, or โ€œ

year

depending on which of the

(^) Song

(^) fi elds the collection should be ordered by. This method should make use of

Comparable

Comparator

(^) objects to return a sorted collection. The application will then update the table with the objects in the new

The application contains an example of using theordering.

(^) JTable

class to display data. This GUI component is paired with a table

model class which performs transformations between the {

row

(^) column

} lookups used by tables and the accessor calls used

The table is enclosed in aon data model objects. It also supplies information like row and column counts and column header names to the table.

JScrollPane

, which displays scroll bars as necessary if the table contents should exceed the size

of the window.

CS 251L

(2) Homework 6

a