Homework Assignment 0: Song Organization and Sorting

advertisement
RAIK183H
Fall 2011
Homework Assignment 0: Song Organization and Sorting
Objectives
The objectives of this homework assignment:
1)
2)
3)
4)
5)
6)
Familiarize with a sorting method using the Insertion, Selection or Exchange sort algorithm.
Familiarize with data member comparison.
Familiarize with the Android SDK.
Familiarize with the concept of encapsulation.
Familiarize with the use of the ArrayList class.
Familiarize with the use of packages and .jar files (Tentative)
Problem Description
Happy with your previous work, your employer would now like you not only to make a program
that looks nice, but sounds nice as well – a music player application for the Android phone! They
have finished most of the surface work already, but having no knowledge of proper sorting
algorithms, they leave the sorting of song information to you. They would like you to use an
“insertion”, “selection” or “exchange” type of sorting to organize the user’s song files, based on
various song statistics such as artist or album.
The Song class has been included for your convenience, and has the following data members and
methods at your disposal:
private String name, artist, album, genre, filepath, trackNum;
public Song(){};
public String getName(){};
public void setName(String name){};
public String getArtist(){};
public void setArtist(String artist){};
public String getAlbum(){};
public void setAlbum(String album){};
public int getTrackNum(){};
public void setTrackNum(int trackNum){};
public String getGenre(){};
public void setGenre(String genre){};
public String getFilepath(){};
public String setFilepath(String filepath){};
In short, your program must sort song information by artist, album, song name, genre, and
track number, separately. Additionally, it should be able to organize information
alphanumerically by artist, then album, then track number, if the user so chooses. The user
should be able to choose which information to sort by and have the program loaded according to
these preferences.
In order to expedite the process, the company has provided all but the sorting algorithms
themselves for you to work with. The sorting algorithms should be used within the sortArtists(),
sortAlbums(), sortSongs(), sortTrackNums(), sortGenres() and organize() methods provided
within the program. These methods all exist within the SongDisplay class, the activity class
through which the songs from the Android device are displayed. The SongDisplay class, along
with all other classes provided, has Javadoc documentation outlining the uses of all methods and
classes at your disposal. Upon proper completion of these methods, the program should run
correctly in the Android emulator for Eclipse.
Challenge – Extra Credit (10 points)
In order to improve the efficacy of the application, your employer suggests that you use
advanced sorting algorithms rather than the simplistic ones. Test one of these algorithms (heap
sort, merge sort, quick sort) in the organize() method of your program, and compare the number
of comparisons and swaps your advanced algorithm requires to the number your previous simple
algorithm required. Include your findings in your README.txt.
Submission Procedure
It is highly recommended that you read the grading policy and grading guidelines on the course
website for a complete explanation of how the assignments will be graded. Remember, your
program should follow a good programming style, including plenty of comments – both inline
documentation and Javadoc documentation, and perform all of the functionality outlined above.
Also, in your README.txt, state whether you are implementing the extra credit functionality.
There are two submission steps:
1) You must “handin” the following files on-line:
1. Altered source files: SongDisplay.java *.java
2. Compiled files: SongDisplay.class *.java
3. Readme file: README.txt
4. Screenshots of your GUI: test_screens.txt
2) You must submit a stapled paper copy of a coversheet, your altered source files, the
README.txt file, and your screenshots.
Download