So I'm super new to the programming thing, I've done a bit of work with C and lisp, but I need help real bad with java. I need to create a class called Artist which "minimally stores the name of the artist as a string, the genre of music of the Artist as a string, and the year in which the artist “Made It Big”." and it should have "a number of appropriate getters, setters, and constructors" I'm given the class Driver for the information, but how do I pass elements of the array as inputs for Artist? Thanks ahead of time
Name:
Anonymous2009-09-13 20:23
and this is the driver class:
public class Driver {
Artist[] artists = new Artist[9];
Song[] songs = new Song[25];
int noOfArtists =0;
int noOfSongs =0;
public Driver()
{
artists[0] = new Artist("Steely Dan", "Rock", "1969");
artists[1] = new Artist("Jimmy Buffet", "Calepso", "1972");
artists[2] = new Artist("Pink Floyd", "Rock", "1969");
artists[3] = new Artist("Tracy Chappman", "Folk", "1988");
artists[4] = new Artist("Hank Williams", "Country", "1934");
artists[5] = new Artist("Dave Mathews Band", "Rock", "1994");
artists[6] = new Artist("Jason Meraz", "Rock", "2008");
artists[7] = new Artist("Train", "Jam Band", "1995");
artists[8] = new Artist("Martin Zeller", "Rock", "1992");
noOfArtists = 9;
songs[0] = new Song("Another Brick in the Wall", "1981", artists[2]);
songs[1] = new Song("Money", "1974", artists[2]);
songs[2] = new Song("Margetaville", "1973", artists[1]);
songs[3] = new Song("A White Sportcoat and a pink Crustacen", "1977", artists[1]);
songs[4] = new Song("Reelin' in the years", "1969", artists[0]);
songs[5] = new Song("Dr. Woo", "1972", artists[1]);
songs[6] = new Song("Cousin Dupre", "2003", artists[1]);
songs[7] = new Song("Bike", "1972", artists[2]);
songs[8] = new Song("Fast Car", "1992", artists[3]);
songs[9] = new Song("Telling Stories", "2003", artists[3]);
songs[10] = new Song("Talking About a Revolution", "1992", artists[3]);
songs[11] = new Song("A Permanent Reminder of a Tempory feeling", "2004", artists[1]);
songs[12] = new Song("A Cuban Crime of Passion", "1974", artists[1]);
songs[13] = new Song("Hey Good Lookin'", "1946", artists[4]);
songs[14] = new Song("Your Chetin' Heart", "1948", artists[4]);
songs[15] = new Song("Cold, Cold Heart", "1949", artists[4]);
songs[16] = new Song("Honky Tonkin'", "1950", artists[4]);
songs[17] = new Song("Satellites", "1994", artists[5]);
songs[16] = new Song("Ants Marching", "1994", artists[5]);
songs[17] = new Song("Crash Into Me", "1997", artists[5]);
songs[18] = new Song("Typical Situation", "2001", artists[5]);
songs[19] = new Song("Lucky", "2008", artists[6]);
songs[20] = new Song("I'm Yours", "2008", artists[6]);
songs[21] = new Song("Meet Virgina", "1999", artists[7]);
songs[22] = new Song("Drops of Jupiter", "2001", artists[7]);
songs[23] = new Song("Clues", "1997", artists[8]);
songs[24] = new Song("All I Need", "1997", artists[8]);
int noOfSongs = 25;
}
public Artist[] getArtists() {
return artists;
}
public Song[] getSongs() {
return songs;
}
public int getNoOfArtists() {
return noOfArtists;
}
public int getNoOfSongs() {
return noOfSongs;
}
}
Name:
Anonymous2009-09-13 20:27
Artist fagtard = new Artist(Driver.whatever[i], Driver.somethingElse[i]);
Name:
Anonymous2009-09-13 20:45
im sorry, but could you explain a bit further? it didnt make sense to me. im sure i sound like a retard. this is also the first thing ive ever tried writing in java, so i know nothing. this is what i have so far:
public class Artist {
public static void main(String[] args){
String name;
String genre;
int yearbig;
....
so what exactly do i put after this to store each element from the given array? god i hate my life...
yeah i read that, and i get how i would set the values manually, i just dont know how to pull a piece of information from the array and use it, ie pass the name, genre, and yearbig to Artist
ie pass the name, genre, and yearbig to Artist pass elements of the array as inputs for Artist?
If you're to look at your driver class, this information is supplied in calls to the constructors. Artist(string artistName, string genre, string yearBig)
You do not need to pass elements of any arrays, nor are there any arrays whose elements could supply the necessary information.
yeah, thats what i meant. thanks for the help, i just have minimal idea as to what im doing. we've only had 2 classes thus far, and my teacher has a physical disability so it sounds like he has down syndrome when he talks, and its impossible to pay attention to that for 4 hours straight.
then do your getters and setters (getname, setname, getgenre, setgenre, getyearbig, setyearbig) that just return or modify a value. The Driver class will be used to call the Artist class and the Song class (Which is probably the next class your professor is going to make you code).