System Description:
Create the necessary Java classes that will simulate a store selling music CDs. The complete system will contain 3 Java classes. The descriptions for each class is follows:
CDException.java
- Purpose: This class extends Exception and will be used to make CompactDisc objects self-validating.
- Contains 1 instance variable:
- String message - the message why the exception is being thrown
- Ensure the instance variable has the correct visibility to enforce encapsulation.
- Contains the following constructor:
- public CDException(String message)
- This is an empty constructor, meaning there is no code inside the { and }
- Contains the following accessor method:
- public String getMessage()
- Contains the following mutator method:
- public void setMessage(String newMessage)
CompactDisc.java
- Purpose:Â This class will be used to model a CD.
- Contains 4 instance variables:
- String artistName - represents the artist's name
- String albumTitle - represents the title of the album
- intnumStock - represents how many CDs are in stock
- double price - represents the price of the CD
- Ensure the instance variables have the correct visibility to enforce encapsulation.
- Contains the following constructor:
- public CompactDisc(String artistName, String albumTitle, intnumStock, double price) throws Exception
- Instead of assignment statements, call the mutator methods to set the instance variables.
- Contains the following 4 accessor methods that simply return their respective instance variable:
- public String getAristName()
- public String getAlbumTitle()
- public intgetStock()
- public double getPrice()
- Contains the following 4 mutator methods and when to throw a CDException
- public void setArtistName(String newArtistName) throws Exception
- If newArtistName is blank, throw a CDException with an appropriate message, else, assign the new name to the appropriate instance variable.
- public void setAlbumTitle(String newAlbumTitle) throws Exception
- If newAlbumTitle is blank, throw a CDException with an appropriate message, else, assign the new title to the appropriate instance variable.
- public void setNumStock(intupdateStock) throws Exception
- If updateStock is a negative number, throw a CDException with an appropriate message, else, assign the new stock to the appropriate instance variable.
- public void setPrice(double newPrice) throws Exception
- If newPrice is a negative number, throw a CDException with an appropriate message, else, assign the new price to the appropriate instance variable.
- Contains the following toString method:
- public String toString()
- Build and return a string that contains all the information of the CD - all the information meaning, use all the instance variables.
- The string should put each piece of information on its own line.
- For example:
   Artist: Michael Jackson
   Album: Thriller
   Stock: 10
   Price: $6.99
LastnameFirstname11.java
- Purpose:Â This will be the driver class that creates and prints CompactDisc objects. It will ask the user for information on a CD, attempt to make a CD object, and print that CD object.
- Replace LastnameFirstname with your own last name and first name.
- This class contains a main method that throws Exception
- Ask the user to enter information to create a CD object.
- Ask for the artist, album title, stock, and price.
- The driver class should not perform any of the validations that will occur in CompactDisc.java.
- For example, when the user enters information for artist name, do NOT check if the length is 0 because that will be checked in CompactDisc.java.
- Create a CompactDisc object with the information from the user.
- Print that object using the object's toString method.
- The exceptions that will need to be caught are: InputMismatchException and CDException.
- You should have 2 catch blocks after the try block.
- The InputMisMatchException is for when the user types in non-numerical data when asked for stock and price of the CD.
- The CDException is for when a CompactDisc object cannot be created because some piece of information does not pass the internal validations on CompactDisc.java.
Submission Instructions:
- Submit the files: CDException.java, CompactDisc.java, and LastnameFirstname11.java to the Digital Dropbox
- DO NOT submit the .class files.
Notes:
- When entering in CD information, any validations that occur in CompactDisc.java will have a seemingly delayed effect until all information for the CD is entered by the user.
- For example, if the user entered a negative number for stock, the program should continue to ask for the price. This is because the validation does not occur until the CompactDisc is created.
- This also means, if the user just hit enter when asked for the artist name, the program should continue to ask for the rest of the information. Not until the CompactDisc object is created will the validation take place.
Extra Credit (10 points):
- An InputMismatchException will occur in 1 of 2 cases:
1.  The user enters a non-integer for stock.
2.  The user enters non-numerical input for price.
- Have a specific error message for which piece of information was incorrectly input.
o   For example, if the user typed in letters when asked for the stock, the output message should say that the stock number was incorrectly entered.
o   If the user typed in letters when asked for the price, the output message should say that the stock number was incorrectly entered.
Example Output #1 (Valid Input)

Example Output #2 (Invalid input for artist name)

Example Output #3a (Stock is negative - handled by CDException)

Example Output #3b (Stock is letters - handled by InputMismatchException)

Example Output #4a (Extra Credit, non-integer stock)

Example Output #4b (Extra Credit, non-numerical price)

Â