package downey.hw1; import java.io.Serializable; import java.util.ArrayList; /** *The required record to use in Hw1 * *@author Tim Downey *@version 08/29/04 */ public class Hw1Record implements Serializable, Cloneable { // instance variables private double price; private int quantity; private String isbn; private String author; private ArrayList optionList; /** *Default constructor for objects of class Hw1Record */ public Hw1Record() { // call constructor with String argument this(""); } /** *Constructor for objects of class Hw1Record with a String argument * *@param isbn The String isbn for this record */ public Hw1Record(String isbn) { // initialise instance variables quantity = 0; price = 0.0; this.isbn = isbn; author = ""; optionList = new ArrayList(); } /** *setQuantity - set the quantity for this book * *@param quantity the quantity of the book */ public void setQuantity(int quantity) { this.quantity = quantity; } /** *getQuantity - get the quantity for this book * *@return the quantity of the book as an int */ public int getQuantity() { return quantity; } /** *getPrice - set the price for this book * *@param price the price of the book as a double */ public void setPrice(double price) { this.price = price; } /** *getPrice - get the price for this book * *@return the price of the book as a double */ public double getPrice() { return price; } /** *setIsbn - set the isbn for this book * *@param isbn the isbn of the book as a String */ public void setIsbn(String isbn) { this.isbn = isbn; } /** *getIsbn - get the isbn for this book * *@return the isbn of the book as a String */ public String getIsbn() { return isbn; } /** *getAuthor - get the author for this book * *@return the author of the book as a String */ public String getAuthor() { return author; } /** *Set the author for the record * *@param author The author as a String */ public void setAuthor(String author) { this.author = author; } /** *displayTable - display the data on separate lines * */ public void displayTable() { String result = ""; String spacer = "\n"; result += "\nISBN: " + getIsbn() + spacer + "Author: " + getAuthor() + spacer + "Quantity: " + getQuantity() + spacer + "Price: " + getPrice(); result += listOption(spacer) + "\n"; System.out.println(result); } /** *displayRow - display the data on one line * */ public void displayRow() { System.out.println(listRecord("\t")); } /*Helper method to display the record data. *The 'spacer' determines the appearance of the data. *"\n" to get separate lines *"\t" to get one line *Creative tricks can be played, like using "