- import java.util.Date;
- import java.text.SimpleDateFormat;
- import java.text.NumberFormat;
- /**
- *
- * This class will define what is the book and what is in the book, essentially its the book it self.
- *
- */
- public class Book
- {
- /////////////////////////////////////////////
- // Member Variables //
- /////////////////////////////////////////////
- private String bookTitle;
- private String bookAuthor;
- private double bookPrice;
- private String bookPublisher;
- private Date bookCopyright;
- /////////////////////////////////////////////
- // Constructors //
- /////////////////////////////////////////////
- /**
- * Class constructor.
- */
- public Book()
- {
- bookTitle = "test";
- bookAuthor = "Blake";
- bookPrice = 0;
- bookPublisher = "Marvel";
- bookCopyright = new Date();
- }
- /**
- * Class constructor specifying the different parameters that it takes.
- * @param title this is the title of the book.
- * @param author this is the author of the book.
- * @param price this is the cost of the book.
- * @param publisher this is the publisher of the book.
- * @param copyright this is the date the book was copyrighted.
- */
- public Book(String title, String author, double price, String publisher, Date copyright)
- {
- bookTitle = title;
- bookAuthor = author;
- bookPrice = price;
- bookPublisher = publisher;
- bookCopyright = copyright;
- }
- /////////////////////////////////////////////
- // Methods //
- /////////////////////////////////////////////
- /**
- * Gets the book title.
- *
- *
- * @return this returns the book title once it is found.
- */
- public String getBookTitle()
- {
- return(bookTitle);
- }
- /**
- * Gets the the books author name.
- *
- *
- * @return this returns the author of the book being called.
- */
- public String getBookAuthor()
- {
- return(bookAuthor);
- }
- /**
- * Gets the books price.
- *
- *
- * @return this returns the books price when called.
- */
- public double getBookPrice()
- {
- return(bookPrice);
- }
- /**
- * Gets the books publisher.
- *
- *
- * @return this returns the books publisher when called.
- */
- public String getBookPublisher()
- {
- return(bookPublisher);
- }
- /**
- * Gets the books copyright date.
- *
- *
- * @return this returns the books year of copyright.
- */
- public Date getCopyRight()
- {
- return(bookCopyright);
- }
- /**
- * toString, overwritten from original prints things nicely.
- *
- *
- * @return this returns the book title, the author, the price, the publisher and the copyright date..
- */
- public String toString()
- {
- SimpleDateFormat formatter = new SimpleDateFormat("yyyy");
- NumberFormat currency = NumberFormat.getCurrencyInstance();
- return("Book Title: " + bookTitle + " Book Author: " + bookAuthor + " Book Price: " + currency.format(bookPrice) + " Book Publisher: " + bookPublisher + " Book CopyRight Date: " + formatter.format(bookCopyright));
- }
- }
Book - new
By: microhaxo | Date: Apr 11 2009 20:58 | Format: None | Expires: never | Size: 3.14 KB | Hits: 905
Latest pastes
18 hours ago
21 hours ago
1 days ago
2 days ago
2 days ago