For this assignment, you will add two features to your homework 9 solution. Start by creating a hw10 subdirectory, then copy your hw09 solution to your hw10 directory, and then copy my hw10db.txt CD database file for testing purposes:
% cd cs21 % mkdir hw10 % cd hw10 % cp ../hw09/*.java . % cp ../hw09/Makefile . % cp ~newhall/public/cs21/hw10/hw10db.txt .
To the CDInfo class add a compareTo method that compares to CDInfo object by:
For example, the following CDInfo objects:
james Brown, Get on the Good Foot, 1972
Charles Mingus, Mingus Ah Um, 1959
X, Under the Big Black Sun, 1982
X, More Fun in the New World, 1983
are in this order when sorted:
Charles Mingus, Mingus Ah Um, 1959
X, More Fun in the New World, 1983
X, Under the Big Black Sun, 1982
james Brown, Get on the Good Foot, 1972
(note: the ASCII ordering of characters means that strings that start with
space or tab chars will come before any strings that start with alphabetic
chars, and strings starting with upper-case chars will come before
strings starting with lower-case chars)
EqualIgnoringWhiteCase(" hello there ", "HELLO THERE")
Next, change the methods in the CDInfo class used by menu options (1) and (2) to compare two CDInfo objects author and title fields so that they call your EqualIgnoringWhiteCase method instead of the String class' compareTo method. As a result, menu options (2) in the CDDMgr program should match a CDs entitled "Greatest Hits" and " greatest hits " to a query for all CDs entitled "greatest hits", for example. And, menu option (1) should work in a similar way.
There is documentation on the String class on the Tues week 3 in-class assignment page.
% java CDDBMgr hw10db.txt
There are 15 CDS.
**** MENU OPTIONS ****
1) to see all works by a given artist
2) to see all albums with a given title
3) to see all albums released in a give year
4) to see the complete list
5) to add a new CD to the collection
6) to quit
***********************
Enter your choice: 4
patti SMITH, Easter , 1979
Bob Marley, Survival, 1979
Charles Mingus, Ah Um, 1959
De La Soul, 3 Feet High and Rising, 1989
Funkadelic, GREATEST HITS, 1978
James Brown, greatest hits , 1990
James Brown, Get on the Good Foot, 1972
Patti Smith, Horses, 1975
Public Enemy, It Takes a Nation of Millions to Hold Us Back, 1988
Sleater-Kinney, Dig Me Out, 1997
Sly & the Family Stone, Fresh, 1973
Sly & the Family Stone, There's a Riot Goin' On, 1971
X, More Fun in the New World, 1983
X, Under the Big Black Sun, 1982
the specials, greatest hits, 1995
-----------------------------------------------
There are 15 CDs
**** MENU OPTIONS ****
1) to see all works by a given artist
2) to see all albums with a given title
3) to see all albums released in a give year
4) to see the complete list
5) to add a new CD to the collection
6) to quit
***********************
Enter your choice: 1
Enter the name of the artist: patti SMITh
Albums by patti SMITh:
--------------------------------------------
patti SMITH, Easter , 1979
Patti Smith, Horses, 1975
--------------------------------------------
There are 2 albums by patti SMITh
**** MENU OPTIONS ****
1) to see all works by a given artist
2) to see all albums with a given title
3) to see all albums released in a give year
4) to see the complete list
5) to add a new CD to the collection
6) to quit
***********************
Enter your choice: 2
Enter a CD title: greATEST hiTS
CDs named greATEST hiTS:
--------------------------------------------
Funkadelic, GREATEST HITS, 1978
James Brown, greatest hits , 1990
the specials, greatest hits, 1995
--------------------------------------------
There are 3 CDs named greATEST hiTS
**** MENU OPTIONS ****
1) to see all works by a given artist
2) to see all albums with a given title
3) to see all albums released in a give year
4) to see the complete list
5) to add a new CD to the collection
6) to quit
***********************
Enter your choice: 5
Enter the artist's name: De La Soul
Enter the album title: de la soul is dead
Enter a release year: 1991
**** MENU OPTIONS ****
1) to see all works by a given artist
2) to see all albums with a given title
3) to see all albums released in a give year
4) to see the complete list
5) to add a new CD to the collection
6) to quit
***********************
Enter your choice: 4
patti SMITH, Easter , 1979
Bob Marley, Survival, 1979
Charles Mingus, Ah Um, 1959
De La Soul, 3 Feet High and Rising, 1989
De La Soul, de la soul is dead, 1991
Funkadelic, GREATEST HITS, 1978
James Brown, greatest hits , 1990
James Brown, Get on the Good Foot, 1972
Patti Smith, Horses, 1975
Public Enemy, It Takes a Nation of Millions to Hold Us Back, 1988
Sleater-Kinney, Dig Me Out, 1997
Sly & the Family Stone, Fresh, 1973
Sly & the Family Stone, There's a Riot Goin' On, 1971
X, More Fun in the New World, 1983
X, Under the Big Black Sun, 1982
the specials, greatest hits, 1995
-----------------------------------------------
There are 16 CDs
**** MENU OPTIONS ****
1) to see all works by a given artist
2) to see all albums with a given title
3) to see all albums released in a give year
4) to see the complete list
5) to add a new CD to the collection
6) to quit
***********************
Enter your choice: 3
Enter a release year: 1979
CDs released in 1979:
--------------------------------------------
patti SMITH, Easter , 1979
Bob Marley, Survival, 1979
--------------------------------------------
There are 2 CDs released in 1979
**** MENU OPTIONS ****
1) to see all works by a given artist
2) to see all albums with a given title
3) to see all albums released in a give year
4) to see the complete list
5) to add a new CD to the collection
6) to quit
***********************
Enter your choice: 6
bye, bye