Ok wrote this program out, compile it it compiles, when i run it it starts off nicely, but when i enter Album Name it gives me an error. Neone know where im going wrong.....
import javax.swing.*;
public class CdStorage
{
public static void main (String[] args)
{
String menu_choice;
int menu;
menu_choice = JOptionPane.showInputDialog("Enter 1 to enter a new CD entry");
menu = Integer.parseInt(menu_choice);
CdRecord[] array = new CdRecord[5];
while (menu == 1)
{
array[0] . artist_name = JOptionPane.showInputDialog("Enter Album Name");
//System.out.println ("array[0]");
array[0].printCdRecord();
}
}//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 ()
{
String o = "Artist Name: " + artist_name + "\nAlbum Name: " +album_name+"\nNo. Of Tracks: " + no_of_tracks;;
System.out.println(o);
}
}//end class cdstorage