Problem Statement |
|
You are given a collection of music files that have each been tagged with the artist, album, track number, and song title. However, the actual file names do not follow any standard format. Given a desired naming format, determine the proper names for all of the files in the collection. You are given four String[]s, artists, albums, tracks, and titles, which contain the artist, album, track number, and song title, respectively, for all the music files. Element i of each String[] corresponds to the ith file. You are given the desired file name format as a String, format. This String will contain only characters from "ABTS -()._" (quotes for clarity only). To determine a file name, replace all occurrences of 'A', 'B', 'T', and 'S' in format with the artist, album, track number, and song title, respectively. All other characters should remain untouched. For example, if format = "A - B - T) S", the artist is "The Beatles", the album is "Rubber Soul", the track number is "07", and the song title is "Michelle", the file should be named "The Beatles - Rubber Soul - 07) Michelle". Return a String[] containing the file names for all the songs in the collection. The ith element of the return String[] should correspond to the song represented by the ith elements of the four String[] parameters. |
Definition |
|
Class: |
SongRenamer |
Method: |
rename |
Parameters: |
String[], String[], String[], String[], String |
Returns: |
String[] |
Method signature: |
String[] rename(String[] artists, String[] albums, String[] tracks, String[] titles, String format) |
(be sure your method is public) | |
|
|
Constraints |
- |
artists, albums, tracks, and titles will each contain between 1 and 20 elements, inclusive. |
- |
artists, albums, tracks, and titles will each contain the same number of elements. |
- |
Each element of artists, albums, tracks, and titles will contain between 1 and 20 characters, inclusive. |
- |
Each element of artists, albums, tracks, and titles will contain only letters ('a'-'z', 'A'-'Z'), digits ('0'-'9'), and spaces. |
- |
format will contain between 1 and 10 characters, inclusive. |
- |
format will contain only characters from the String "ABTS -()._" (quotes for clarity only). |
Examples |
0) |
|
|
{"Marvin Gaye", "Marvin Gaye"} |
{"Here My Dear", "Whats Going On"} |
{"09", "7"} |
{"Annas Song", "Right On"} |
"A - B-T-S" | |
Returns:
{"Marvin Gaye - Here My Dear-09-Annas Song",
"Marvin Gaye - Whats Going On-7-Right On" } |
| |
1) |
|
|
{"Booker T and the MGs"} |
{"McLemore Avenue"} |
{"Number Two"} |
{"Something"} |
"T. S_B_(S)" | |
Returns: {"Number Two. Something_McLemore Avenue_(Something)" } |
format can contain multiple instances of the same tag. Also, track numbers do not have to contain only digits. | | |
2) |
|
|
{"The Beatles", "The Supremes", "YellowMatterCustard"} |
{"A Hard Days Night", "A Bit Of Liverpool", "One Night In NYC"} |
{"Twelve", "Siete", "7"} |
{"You Cant Do That", "You Cant Do That", "You Cant Do That"} |
"S (S) S" | |
Returns:
{"You Cant Do That (You Cant Do That) You Cant Do That",
"You Cant Do That (You Cant Do That) You Cant Do That",
"You Cant Do That (You Cant Do That) You Cant Do That" } |
| |
3) |
|
|
{" The Leading Spaces"} |
{" "} |
{"Trailing Space "} |
{" s p a c e s "} |
"S._A_B(T)" | |
Returns: {" s p a c e s ._ The Leading Spaces_ (Trailing Space )" } |
| |
4) |
|
|
{"Ignored"} |
{"Unnoticed"} |
{"000"} |
{"Uncredited"} |
"()-(). " | |
Returns: {"()-(). " } |
format doesn't necessarily have to contain any tags. | | |