// Arup Guha
// 10/12/2026
// Song class for
// Solution to Fall 2026 COP 3330 Program #6: Billboard Top 100,0000

public class Song implements Comparable<Song> {

	private String title;
	private String artist;
	private int year;
	private int sales;
	private long streams;
	
	// Usual constructor.
	public Song(String myT, String myA, int myY, int mySales, long myStreams) {
		title = myT;
		artist = myA;
		year = myY;
		sales = mySales;
		streams = myStreams;
	}
	
	// We need this to implement comparable.
	public int compareTo(Song other) {
		
		// More sales is better (sorted first).
		if (this.sales != other.sales)
			return other.sales - this.sales;
			
		// Then streams...the long class can do this!
		if (this.streams != other.streams)
			return Long.compare(other.streams, this.streams);
			
		// Last tie-breaker.
		return this.title.compareTo(other.title);
	}
	
	// What was requested.
	public String toString() {
		return title+", "+artist+" "+year+" "+sales+" "+streams;
	}
	
	// Returns the year of the song.
	public int getYear() {
		return year;
	}
	
}