Question

in java

Assignment 2 is the first in a multipart series of assignments. The overall topic of the assignments will be the design and implementation of a system for keeping track of the holdings of a library This first assignment focuses on the development of a custom class to represent a book that belongs to the library. The class should be named Book and be based on the corresponding real-world concept of a book, and be able to represent the characteristics of a book that would be useful in a system designed to manage library holdings. In particular, your custom class should represent and track the following book characteristics: title (a String), author (a String), number of pages (an integer), and status (boolean). The status attribute should represent whether a book is currently checked out (a status value of true) or not checked out (a status value of false) In your custom class, include a constructor that can be used to initialize book objects as they are created. It should accept 3 parameters: a book title, a book author, and the number of pages in the book. Each of the values specified for the parameters should be used in the constructor to initialize the corresponding field of a new book object. The initial value of the status field for the book should be set to “false to indicate it is currently not checked out.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Program

public class Book

{

                String title;

                String author;    //creating’s objects of the doss

                int numberOfPages;

                boolean status;

                public void Book (String title,String author,int numberOtPages){

                                this.title=title;

                                this.author=author;        //constructor to intiatize

                                this.,AmberOWages=nunberOfPages;

                }

                public void setTitle(String title){

                                this.title=title;

                }

                public void getTitle(){

                                return title;

                }

                public void setAuthor(String author){

                                this.author=author;        //differnt methods

                }

                public void getAuthor(){

                                return author;

                }

                public void setPages(int pages){

                                this.NumberOfPages=numberOfPages;

                }

                public void getPages(){

                                return numberOtPages;

                }

                public void setStatus(boolean status){

                                this.status=status;

                }

                public void setStatus(boolean status){

                                this.status=status;

                }

                public void getStatus(){

                                return status;

                }

public String toString(){

                System.out.println(" ' "A-title+","vauthor+","*ForberOfPages,","+status+" ' " ;

                }

                }

class MyBooks{

                public static void main(String []args){

                                Book Bookl = new Book("java programmng","Ronald pierce",475);

                                Book Boob_ = new Book("javaprecisely","peter sestoft",199);

                                Book Book3 = new Book("python programming for beginners","Bill ullman", 8);

                System.out.println("The original values of book objects are");

                Book1.toString();

                Book2.toString();

                Book3.toString();

                Book2.setPages(124);

                Book1.setTitle("Introduction to java programming");

                Book3.setAuthor("richard ullman");

                System.out.println("The original values of book objects are");

                Book1.toString();

                Book2.toString();

                Book3.toString();

                }

                }

Add a comment
Know the answer?
Add Answer to:
in java Assignment 2 is the first in a multipart series of assignments. The overall topic...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • You need to program a simple book library system. There are three java classes Book.java   //...

    You need to program a simple book library system. There are three java classes Book.java   // book object class Library.java   //library class A2.java //for testing The Book.java class represents book objects which contain the following fields title: a string which represents the book title. author: a string to hold the book author name year: book publication year isbn: a string of 10 numeric numbers. The book class will have also 3 constructors. -The default no argument constructor - A constructor...

  • Using C++ Skills Required Create and use classes Exception Handling, Read and write files, work vectors....

    Using C++ Skills Required Create and use classes Exception Handling, Read and write files, work vectors. Create Functions, include headers and other files, Loops(while, for), conditional(if, switch), datatypes,  etc. Assignment You work at the computer science library, and your boss just bought a bunch of new books for the library! All of the new books need to be cataloged and sorted back on the shelf. You don’t need to keep track of which customer has the book or not, just whether...

  • You are going to model a Book in a library. The Book class should contain a...

    You are going to model a Book in a library. The Book class should contain a title and an author (exactly 1 author is OK). Also, a book can be checked out and returned by a student. A Book object should be able to identify the student who currently holds the book. 1.Design the public interface (public constructor and public methods) for a class Book. You can use String to represent title, author, and student. 2. Implement the class Book...

  • In this assignment you will implement software for your local library. The user of the software...

    In this assignment you will implement software for your local library. The user of the software will be the librarian, who uses your program to issue library cards, check books out to patrons, check books back in, send out overdue notices, and open and close the library. class Calendar We need to deal with the passage of time, so we need to keep track of Java. Declare this variable as private int date within the class itself, not within any...

  • Programming language: Java Design an application that has three classes. The first one, named Book describes...

    Programming language: Java Design an application that has three classes. The first one, named Book describes book object and has title and number of pages instance variables, constructor to initialize their values, getter methods to get their values, method to String to provide String representation of book object, and method is Long that returns true if book has over 300 pages, and returns false othewise. Provide also method char firstChard) that returns first cahracter of the book's title. The second...

  • The first part is “addBook method” the Second part is “checkOut method” the third part is...

    The first part is “addBook method” the Second part is “checkOut method” the third part is “isAvailable method” and the fourth is “__str__ method”. What you have to do is complete the sample code provided below. do not change the sample code and print result. The program's goal is to keep track of books in a library. Books are stored in dictionaries, with the book title as the key. Source Code is: class Library: bookCount = 0 def __init__(self): self.cardCatalog...

  • This assignment consists of a series of SQL questions. For each question, you will need to...

    This assignment consists of a series of SQL questions. For each question, you will need to include: • SQL query. • An explanation of the query. Please include explanations as a comment AFTER your query, e.g., enclosed within a /* comments block */ ). See the first example in the SQL tutorial for a comment. You don’t need to explain straightforward code in comments. Only the parts that are interesting or different, so that we understand what you did. Question-1...

  • C++ In this homework, you will implement a single linked list to store a list of computer science textbooks. Ever...

    C++ In this homework, you will implement a single linked list to store a list of computer science textbooks. Every book has a title, author, and an ISBN number. You will create 2 classes: Textbook and Library. Textbook class should have all above attributes and also a "next" pointer. Textbook Туре String String String Attribute title author ISBN Textbook* next Library class should have a head node as an attribute to keep the list of the books. Also, following member...

  • Programming Assignment This is a database course using Open Office Database. Assume that you have been...

    Programming Assignment This is a database course using Open Office Database. Assume that you have been given the task of creating a system for a library to keep track of their books, the borrowers of the books, and the books that are currently lent out. Your first step will be to create the relations necessary for this system. Book will need information such as a unique identifier for each book, title, author, ISBN number, date of publication, cost. Borrower will...

  • Case Study:UniversityLibrarySystem This case is a simplified (initial draft) of a new system for the University...

    Case Study:UniversityLibrarySystem This case is a simplified (initial draft) of a new system for the University Library. Of course, the library system must keep track of books. Information is maintained about both book titles and the individual book copies. Book titles maintain information about title, author, publisher, and catalog number. Individual copies maintain copy number, edition, publication year, ISBN, book status (whether it is on the shelf or loaned out), and date due back in. The library also keeps track...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT