COM 1204 Assignment #5. Due: Tuesday, 21 May 2002 Working in teams, you will implement the program described below. All members of the team should expect to receive the same grade for this assignment. Your team's grade for this assignment will be based on the correctness and readability of your code, and by how well you hide your code from other teams. Collaboration between students on the same team is required, but collaboration between students who are not on the same team is forbidden. You are responsible for keeping your code hidden from all other teams. Instructions for submitting this assignment will be given in class. Late assignments may be discounted, and very late assignments may be discarded. -------------------------------------------------- The instructor is providing some code for this assignment in /course/com1204/.www/will/Assignments/A5. That directory contains Jeff.java repertoire/ParseRepertoire.java repertoire/Tuning.java setlist/RepBuilder.java Your team will modify setlist/RepBuilder.java. Your team will probably create other Java files as well, but all of the code that your team creates or modifies should go in the setlist package. You should not modify Jeff.java or any code in the repertoire package. -------------------------------------------------- The program is for a guitarist named Jeff, who maintains a repertoire of about one hundred tunes. Jeff desires a computer program that will select any given number of tunes from his repertoire at random. He also wants the computer program to list the selected tunes in an order that would minimize the amount of retuning that Jeff would have to do when performing the tunes in that order. Jeff's repertoire is listed within in a text file (called the database), and the instructor will provide Java code that parses the database and calls a stub routine for each tune in the repertoire. These stubs are in setlist/RepBuilder.java, which you will need to modify to do whatever is needed by your team's program design. Each tune in Jeff's repertoire will be identified by its name, which will be a non-empty string. Most tunes will have other information associated with them as well, such as the name of the composer (a string), opus (an int) and number (an int), year of composition (an int), and the tuning (see below) that Jeff uses to perform the tune. The only information that appears to be immediately relevant to Jeff's program, however, are the title and tuning. If Jeff's database contains a tune with no explicit tuning, then Jeff performs that tune in the tuning that is considered standard for six-string guitar, which is EADGBE. This sequence of letters names the pitch class that is sounded by each of the guitar's six strings. By convention, the leftmost letter names the pitch sounded by the sixth string, and the rightmost letter names the pitch sounded by the first string. Other tunings are obtained from standard tuning by tuning certain strings up or down some integral number of half-steps. For example, the EADF#BE tuning that Jeff uses on some tunes is obtained by tuning the third string down one half-step, from G to F#. The DADGAD tuning that Jeff uses on some tunes in obtained by tuning the first, second, and sixth strings down two half-steps from standard tuning. The parsing code that is provided by the instructor will represent a tuning as a six-element int array in which each element records the number of half-steps that a string is tuned up or down from standard tuning; zero indicates that the string is tuned to its standard pitch, a positive integer indicates that it is tuned up, and a negative integer indicates that the string is tuned down. Element 0 of the array gives the tuning for the first string, element 1 for the second string, and so on. For example, the DADGAD tuning is represented by an array whose elements are <-2, -2, 0, 0, 0, -2>. The DGDGBbD tuning is represented by an array whose elements are <-2, -1, 0, 0, -2, -2>. The EADF#BE tuning is represented by an array whose elements are <0, 0, -1, 0, 0, 0>. The program takes two command-line arguments. The first is a non-negative integer n that tells how many tunes should be selected. The second is the name of the file that contains the database. The instructor will provide code for parsing these command-line arguments. The output of the program is to be written to System.out. If the input n is negative or is larger than the number of tunes in Jeff's repertoire, then the output should be an appropriate error message. Otherwise the output should be a list of n randomly selected tunes, one per line, with each line giving both the name of the tune and, within parentheses, the tuning as Jeff would like to see it, for example DADGAD. If the tune is in standard tuning, then the tuning can be omitted from the line, and Jeff would actually prefer that the tuning not be printed in that case. It is important that the order in which the tunes are listed minimizes retuning.