Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Book {
- //Private Variables
- private int isbn;
- private String title;
- private String author;
- private double price;
- //GET isbn
- public int getISBN(){
- return this.isbn;
- }
- //SET isbn
- public void setISBN(int isbn){
- this.isbn = isbn;
- }
- //GET title
- public String getTitle(){
- return this.title;
- }
- //SET title
- public void setTitle(String title){
- this.title = title;
- }
- //GET author
- public String getAuthor(){
- return this.author;
- }
- //SET author
- public void setAuthor(String author){
- this.author = author;
- }
- //GET price
- public double getPrice(){
- return this.price;
- }
- //SET price
- public void setPrice(double price){
- this.price = price;
- }
- public Book() //default constructor Or parameterless constructor
- {
- this.isbn = 0000;
- this.title = "Unknown";
- this.author = "Unknown";
- this.price = 0000;
- }
- public Book(int isbn, String title, String author, double price)
- {
- this.isbn=isbn;
- this.title=title;
- this.author = author;
- this.price = price;
- }
- public void displayBook()
- {
- System.out.println("\n\n\t\tISBN: " + this.isbn + "\n\t\tTitle: " + this.title + "\n\t\tAuthor: " + this.author + "\n\t\tPrice: " +this.price+"\n");
- }
- public String toString(){
- return "\n\n\t\tISBN: " + this.isbn + "\n\t\tTitle: " + this.title + "\n\t\tAuthor: " + this.author + "\n\t\tPrice: " +this.price+"\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement