* Purpose: to create a class that holds information about a record
*/
import javax.swing.JOptionPane;
public class Record {
private int sku; //stores the SKU value of a record
private String artist; //stores the artist of a record
private String album; //stores the album of a record
private double price; //stores the price of a record
private int quan; //stores the quantity of the record in stock
private boolean valid; //represents the validity of the record
//creates an object representing a record
public Record(String skuNum, String art, String abm, String prc, String qnt){
valid = true;
artist = art;
album = abm;
//checks if the fields have data
if(artist.length() == 0 || album.length() == 0)
valid = false;
//determines if the numbers are valid format
try{
sku = Integer.parseInt(skuNum);
price = Double.parseDouble(prc);
quan = Integer.parseInt(qnt);
//checks if the numbers are in range
if(sku }catch(NumberFormatException e){
valid = false;
}//end try - catch
}//end Record constructor
//getter method for the record's SKU
public int getSku() {
return sku;
}//end getSku
//getter method for the record's album
public String getAlbum() {
return album;
}//end getAlbum
//getter method for the record's artist
public String getArtist() {
return artist;
}//end getArtist
//getter method for the record's price
public double getPrice() {
return price;
}//end getPrice
//getter method for the record's quantity in stock
public int getQuan() {
return quan;
}//end getQuan
//setter method for the quantity in stock
public void setQuan(int quan) {
this.quan = quan;
}//end setQuan
//getter method for the validity of the record (notifies the user as well)
public boolean getValidity(){
String message = "";
//checks validity of record and constructs a message to the user based on that
if(valid)
message = "Record Successfully Added";
else
message = "Invalid input, record not added";
JOptionPane.showMessageDialog(null, message, "Add Record", JOptionPane.PLAIN_MESSAGE);
return(valid);
}//end getValidity
}//end Record
Published by Chris Chen
Chris is currently attending the University of California, Berkeley seeking an undergraduate's degree in Electrical Engineering Computer Science. He enjoys playing basketball, practicing kendo, hanging out w... View profile
- Current State of the Public School SystemThis article takes a look at some key issues facing the students of the public school system today. This was written from an objective point of view to try out a different style for me.
- Public Schools Hate HomeschoolingThere are several reasons why public schools truly hate parents who choose to homeschool their children. Due to these reasons public schools choose to harass these parents for what is these parents' right by law.
- Tips on Public Speaking for the Total CowardThis is the basic bible for not only getting through any public speaking engagement, but EXCELLING at it.
Should There Be an Asterisk Next to Barry Bonds Once He Breaks the Home...Barry Bonds is no doubt one of the greatest and most exciting players to ever play the game of baseball. Anyone who knows a little about sports knows that he is about to break H...- How to Start Your Own Record LabelI have owned my own record label for over a year, now, and it was very easy to get started. All it takes is a little money, a little determination, and a little research.
- Being a Public Relations Specialist
- British Billion Dollar Cyber-babe awarded Guinness World Record
- WEIRD NEWS: New World Record Set for Largest Coconut Orchestra
- World-wide Cd Sales Are Worst in SoundScan History, and the Record Labels Only Hav...
- Public Relations Philosophy, Part 1
- Five Tips to Combat the Fear of Public Speaking
- The Bible in Public Schools: Constitutional or Unconstitutional?



