Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package finalprogrambook;
- /**
- *
- * @author StoneBoneThone
- *
- */
- public class Book
- {
- //These are the fields for this class
- //Maybe modify, like modify book year (some might be char)
- private String title;
- private String author;
- private int numberOfPages;
- private String publisherName;
- private int bookYear;
- public Book thatBook;
- //These are the constructors for the class
- //This constructor accepts values for the fields above
- public Book (String theTitle, String theAuthor, int numPages,
- String pubName, int theBookYear)
- {
- theTitle = title;
- author = theAuthor;
- numberOfPages = numPages;
- publisherName = pubName;
- theBookYear = bookYear;
- }
- //Copy constructor makes a copy of a Book object
- public Book (Book copyBookObject)
- {
- thatBook = copyBookObject.thatBook;
- }
- // These are the methods for the class
- //This method returns the value of title field
- public String getTitle()
- {
- return title;
- }
- //This method accepts a string argument, assigned to the author field
- public void setAuthor (String setAuthor)
- {
- author = setAuthor;
- }
- // This method accepts a Book object as arg
- //If arg object has same number of pages as calling object, method returns true
- public boolean hasSameNumPages (Book pageAmount)
- {
- boolean status; //rename
- if (numberOfPages == pageAmount.numberOfPages )
- status = true;
- else
- status = false;
- return status;
- }
- //This method returns all values of the fields in a friendly, readable fashion
- public String toString()
- {
- String returningString = " The name of the author is " + author + //need setauthor here?
- ", the number of pages is " + numberOfPages + "." +
- "\n" + publisherName + "published it in " + bookYear;
- return returningString;
- }
- }
Add Comment
Please, Sign In to add comment