-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTrack.java
60 lines (53 loc) · 1.73 KB
/
Track.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Title: Midterm Project
// Files: Album.java, ArtistComparator.java, Catalog.java,
// CatalogHelper.java, Track.java
// Author: Sabina
// Description of Program’s Functionality:
// A program to read a text file and process its content into album objects
// sort them by album name or artist name upon users request, also allowing
// users to search for an album by album name or all albums by a certain
// artist. This program also allows the user to add an album to the catalog
// by entering the appropriate information.
//
//////////////////////////// 80 columns wide/////////////////////////////////
public class Track implements Comparable<Track>
{
//Instance Variable
String song; //The name of a song
/**
* Contructs a track object.
* @param song
*/
public Track(String song)
{
this.song = song;
}
/**
* Acessor for the song
* @return song
*/
public String getSong()
{
return song;
}
@Override
/**
* Compare method that from comparable interface to compare songs
* @param song a track on the album
* @return the comparison of one song to another
*/
public int compareTo(Track song)
{
return this.getSong().compareToIgnoreCase(song.getSong());
}
/**
* Return a string version of the track object
* @return track object as a string
*/
public String toString()
{
return this.song + " ";
}
}