Hello.
As i couldnt work out my problem with my other version, i re-wrote it in a totally different form,
now my program does display all the entries i make,, but the problem now is
how do stop the dialog box from keep coming up.
For example: i input 2 entries and thats all i want to input; i want those two entries to print out and thats it.
in this case i keep getting the input dialog box untill all my array elements are used up....
neone know how i can fix this problem???
All help apreciated.
import javax.swing.*;
public class CdStorage2
{
public static void main (String[] args)
{
CdRecord[] array = new CdRecord[5];
int i;
for(i=0; i<array.length; i++)
{
array = new CdRecord();
}
for (i=0; i<array.length;i++)
{
array.printCdRecord();
}
} //end main
}//end class
class CdRecord
{
private String artist_name;
private String album_name;
private int no_of_tracks;
public CdRecord ()
{
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);
artist_name =
JOptionPane.showInputDialog("Enter Artist Name");
album_name =
JOptionPane.showInputDialog("Enter Album Name");
no_of_tracks =
Integer.parseInt(JOptionPane.showInputDialog("Enter Number Of Tracks"));
}
public void printCdRecord ()
{
System.out.println("Artist Name: " +artist_name + "\nAlbum Name: " +album_name+"\nNo. Of Tracks: " +no_of_tracks+"\n");
}
}//end class cdstorage