Hi all,
Ok i've started doing a mini project about a CD collection database.
i got the program working ata stage where you can enter a single entry and the record is printed to the screen, the problem im having is i can not seem to modify the program to store an array of CD 'objects' . Each entry in the array needs to be a single object describing a CD.
I also need to add a menu of options like:
1: Input New Entry
2: Print All Entries
3: Quit
if anyone can help i would really apreciate the help.
below is my program of where i have got to so far::
If you copy and paste this you will see it works.
import javax.swing.*;
public class CdStorage
{
public static void main (String[] args)
{
int menu_choice;
CdRecord one = new CdRecord();
one.artist_name = JOptionPane.showInputDialog("Enter artist name.");
one.album_name = JOptionPane.showInputDialog("Enter album name.");
one.no_of_tracks =Integer.parseInt(JOptionPane.showInputDialog("Enter the number of tracks on the album"));
one.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