Hi Guys,
Another quick question.
I want to validate the field of inGenre to either Jazz, Blues, Soul
but I cant get the hang of doing an If statement with Strings
Heres the code
/** * A class that maintains information on a CD. * * @author (Martyn Weber) * @version (Version 1) */ class CD { // The fields. private Artist performer; private String album; private String genre; private int numberOfTracks; private int yearReleased; ////Constructors/////////////////////////////////////////////////////////// public CD (String inalbum, String inGenre, int inNumberOfTracks, int inYearReleased) { album = inalbum; if(inGenre = Soul && inGenre = Jazz && inGenre = Blues){ genre = inGenre; } else{ System.out.println ("#Please make sure that the genre is set to either "Soul" Jazz" or "Blues""); } if(inNumberOfTracks > 1 ){ numberOfTracks = inNumberOfTracks; } else{ System.out.println ("#There must be 1 or more tracks"); } if(inYearReleased > 1901 && inYearReleased < 2003){ yearReleased = inYearReleased; } else{ System.out.println ("#Date of Release Must Be Between 1900 - 2004"); } } public CD () // This is a blank *Constructor* { // and will take *No* *Arguments* } ////These are Accessor Methods///////////////////////////////////////////// public String getAlbum() // This Accessor is used to return { // The title of the Album return album; // } // // public String getGenre() // This Accessor is used to return { // The Genre of the Album return genre; // } // // public int getYear() // This Accessor is used to return { // The Year the Album was created return yearReleased; // } // /////////////////////////////////////////////////////////////////////////// ////These are Mutator Methods/////////////////////////////////////////////// public void setAlbum(String addAlbum) // This Accessor is used to return { // The title of the Album album = addAlbum; // } // // public void setGenre(String addGenre) // This Accessor is used to return { // The Genre of the Album genre = addGenre; // } // // public void setYear(int addYear) // This Accessor is used to return { // The Year the Album was created yearReleased = addYear; // } // /////////////////////////////////////////////////////////////////////////// ////This is a printing *Method* to print a ticket to the screen//////////// public void printVoucher() { System.out.println("|------------------------------------| "); System.out.println("|----------Cryptic Tickets-----------| "); System.out.println("|-----Festival & Concert Bookings----| "); System.out.println("|-----www.cryptictickets.co.cc-------| "); System.out.println("|--------------CD Info---------------| "); System.out.println("|-Album------------------------------| "); System.out.println("|.........." + album +""); System.out.println("|-Genre------------------------------| "); System.out.println("|.........." + genre +""); System.out.println("|-Tracks-----------------------------| "); System.out.println("|.........." + numberOfTracks + ""); System.out.println("|-Release-Year-----------------------| "); System.out.println("|.........." + yearReleased +""); System.out.println("|------------------------------------| "); } }
Thanks in advance