Advertisement
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 exam1retake;
- /**
- *
- * @author localstudent
- */
- public class Book {
- String title;
- String author;
- int pages;
- public Book(String title, String author, int pages) {
- setTitle(title);
- setAuthor(author);
- setPages(pages);
- }
- public Book() {
- this.title = "Title";
- this.author = "Author";
- this.pages = 10;
- }
- public Book(Book book1) {
- setTitle(book1.title);
- setAuthor(book1.author);
- setPages(book1.pages);
- }
- public String getTitle() {
- return title;
- }
- public String getAuthor() {
- return author;
- }
- public int getPages() {
- return pages;
- }
- public void setTitle(String title) {
- this.title = title;
- }
- public void setAuthor(String author) {
- this.author = author;
- }
- public void setPages(int pages) {
- this.pages = pages;
- }
- @Override
- public String toString() {
- return String.format("Title: %s" + "Author: %s" + "Pages: %d", title, author, pages);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement