配列からの売上または変数を比較し、最も売れている商品と最も売れていない商品を印刷できるコードを持っている人はいますか。私はいくつかのことを試しましたが、正確に機能させることはできません。
これが私のコードです。私が最も心配しているのは一番下にあります。
package album;
public class Certifier {
public static void main(String[] args) {
Album zero = new Album(0, "Dark Side of the Moon", "Pink Floyd", 1973, 50000000);
System.out.println("The album information for ablum 0 is: " + zero.toString());
Album one = new Album(1, "Superficial", "Heidi Montag", 2010, 658);
System.out.println("The album information for ablum 1 is: " + one.toString());
Album two = new Album(2, "Fearless", "Taylor Swift", 2011, 3200000);
System.out.println("The album information for ablum 2 is: " + two.toString());
Album three = new Album(3, "Made Up", "Sample Band", 2011, 1300000);
System.out.println("The album information for ablum 3 is: " + three.toString());
Album four = new Album(4, "Concerto One Night", "Andrea Bocelli", 2011, 500008);
System.out.println("The album information for ablum 4 is: " + four.toString());
Album[] albums = new Album[4];
albums[0] = zero;
albums[1] = one;
albums[2] = two;
albums[3] = three;
albums[4] = four;
((Comparable<String>) albums[0]).compareTo(albums[1]);
System.out.println("The highest selling album is");
for (int i=0; i< Album[].length; i++) {
double highestSales;
if (i.getSales()<highestSales)
highestSales= i;
return highestSales;
}
System.out.println("The lowest selling album is");
for (int i=0; i< Album[].length; i++) {
double lowestSales;
if (i.getSales()<lowestSales)
lowestSales= i.getSales();
return i.getName + i.getArtist;
}
}
}