Im very new to java and getting there slowly.
Im working on basic class functions. Im totally fine with get and set, storing objects into an array and recalling them, but im totally stuck with the following:
declare and set max (using cd[0].getCost())
declare and set maxIndex
for each remaining CD
If CD cost is bigger than max
Set max to bigger value
Set maxIndex
output result
my code so far is (And thanks for any help)
Expand|Select|Wrap|Line Numbers
- class CDDriver
- {
- public static void main(String args[])
- {
- CD[] cdList = new CD[10];
- cdList[0] = new CD("Kaiser "," up the khazi ", 9.99);
- cdList[1] = new CD("Oasis "," morning glory ",3.99);
- cdList[2] = new CD("Bob Dylan "," Alreet Sunna ",6.99);
- System.out.println("Artist \t\tTitle\t\tCost");
- System.out.println("====================================");
- for (int i = 0; i < cdList.length; i++)
- System.out.println(cdList[i].getArtist() + " " + cdList[i].getTitle() + " " + cdList[i].getCost());
- // System.out.println(cd1.getArtist() + " " + cd1.getTitle() + " " + cd1.getCost());
- //System.out.println(cd2.getArtist() + " " + cd2.getTitle() + " " + cd2.getCost());
- // System.out.println(cd3.getArtist() + " " + cd3.getTitle() + " " + cd3.getCost());
- }
- }