Okay i've done wat u've told me, but i keep gettin errors. Below is the whole program, can u tell me where im going wrong with my array display...
if possible could u explain also as im kind of a novice at java..
Apreciate ne help..
import javax.swing.*;
public class CdStorage
{
public static void main (String[] args)
{
String menu_choice;
int menu;
menu_choice =
JOptionPane.showInputDialog("Enter:\n 1: New CD entry\n 2: Print\n 3: Quit");
menu = Integer.parseInt(menu_choice);
CdRecord[] array = new CdRecord[5];
array[0] = new CdRecord();
while (menu == 1)
{
array[0] . artist_name =
JOptionPane.showInputDialog("Enter Artist Name");
array[0] . album_name =
JOptionPane.showInputDialog("Enter Album Name");
array[0] . no_of_tracks =
Integer.parseInt(JOptionPane.showInputDialog("Enter Number Of Tracks"));
menu_choice =
JOptionPane.showInputDialog("Enter:\n 1: New CD entry\n 2: Print\n 3: Quit");
menu = Integer.parseInt(menu_choice);
// for (int i = 0; i < array.length; i++);
if (menu == 2)
array[0].printCdRecord();
//for (int i = 0; i < array.length; i++) {
//System.out.println(array[i]);}
if (menu == 3)
System.out.println();
}//end while
}//end main
} // end class CdStorage
class CdRecord
{
public String artist_name;
public String album_name;
public int no_of_tracks;
public CdRecord (String artist, String album, int tracks, int year)
{
artist_name = artist; //stores first argument passed into artist_name
album_name = album; //stores second argument passed into album_name
no_of_tracks = tracks; //stores third argument passed into no_of_tracks
}
public CdRecord()
{
artist_name = "A";
album_name = "B";
no_of_tracks = 0;
}
public void printCdRecord (array[])
{
int i = 0;
for(i=0;i