CODE IN JAVA:
Book.java file:
public class Book {
String title ;
int numOfPages ;
public Book(String title, int numOfPages) {
this.title = title;
this.numOfPages = numOfPages;
}
public String getTitle() {
return title;
}
public int getNumOfPages() {
return numOfPages;
}
public boolean isLong() {
return numOfPages > 300 ;
}
public char firstChar() {
return title.charAt(0);
}
@Override
public String toString() {
return "Book [title=" + title + ",
numOfPages=" + numOfPages + "]";
}
}
Library.java file:
import java.util.ArrayList;
public class Library {
ArrayList<Book> bookShelf ;
Library(){
bookShelf = new
ArrayList<Book>();
bookShelf.add(new Book("Amrutham
Kurisina ratri", 240));
bookShelf.add(new Book("Rich dad
poo dad", 400));
bookShelf.add(new Book("Half girl
friend", 320));
bookShelf.add(new Book("Fountain
head", 180));
bookShelf.add(new Book("Amaravathi
kathalu", 640));
}
String allBooks() {
StringBuffer str = new
StringBuffer("");
for(Book b : bookShelf) {
str.append(b);
str.append("\n");
}
return str.toString() ;
}
Book shortestBook() {
Book shortBook =
bookShelf.get(0);
for(Book b : bookShelf) {
if(b.getNumOfPages() < shortBook.getNumOfPages())
shortBook = b ;
}
return shortBook ;
}
void printBookSelection(int num, char character)
{
for(Book b : bookShelf) {
if(b.getNumOfPages() > num && b.getTitle().charAt(0) ==
character) {
System.out.println(b);
}
}
}
ArrayList<Book> longBooks(){
ArrayList<Book> resultList =
new ArrayList<Book>();
for(Book b : bookShelf) {
if(b.isLong())
resultList.add(b);
}
return resultList ;
}
}
Tester.java file:
import java.util.ArrayList;
import java.util.Scanner ;
public class Tester {
public static void main(String[] args) {
Scanner sc = new
Scanner(System.in);
Library library = new
Library();
System.out.println("Below are the
all books of library : ");
System.out.println(library.allBooks());
System.out.println("\nShortest book
: " + library.shortestBook());
int num;
char c ;
System.out.print("Enter the number
:");
num = sc.nextInt();
System.out.print("Enter the
character:");
c = sc.next().charAt(0);
System.out.println("Below are the
books having pages greater than number and title starting with your
character : ");
library.printBookSelection(num,
c);
ArrayList<Book> longBooks =
library.longBooks();
System.out.println("Below are the
long books: ");
for(Book b : longBooks)
System.out.println(b);
}
}
OUTPUT:

Programming language: Java Design an application that has three classes. The first one, named Book describes...
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...
C# programming
50 pts Question 2:2 1- Create the base class Book that has the following instance variables, constructor, and methods title (String) isbn (String) authors (String) publisher (String) edition ( int) published year (int) Constructor that takes all of the above variables as input parameters. set/get methods ToString method// that return sting representation of Book object. 2-Create the sub class New_Book that is derived from the base class Book and has the following instance variables, constructor, and methods: title...
Design and implement a Java data structure class named BookShelf which has an array to store books and the size data member. The class should have suitable constructors, get/set methods, and the toString method, as well as methods for people to add a book, remove a book, and search for a book. Design and implement a Java class named Book with two data members: title and price. Test the two classes by creating a bookshelf object and five book objects....
1- Create the base class Book that has the following instance variables, constructor, and methods title ( String) isbn ( String) authors (String) publisher (String) edition ( int) published_year (int) Constructor that takes all of the above variables as input parameters. set/get methods ToString method // that return sting representation of Book object. 2- Create the sub class New_Book that is derived from the base class Book and has the following instance variables, constructor, and methods: title ( String) isbn...
Additional info is this will use a total of four classes Book,
BookApp, TextBook, and TextBookApp.
Also uses Super in the TextBook Class section.
Problem 1 (10 points) Вook The left side diagram is a UML diagram for Book class. - title: String The class has two attributes, title and price, and get/set methods for the two attributes. - price: double Вook) Book(String, double) getTitle(): String setTitle(String): void + getPrice() double setPrice(double): void toString() String + The first constructor doesn't...
cs55(java) please. Write a class called Book that contains instance data for the title, author, publisher, price, and copyright date. Define the Book constructor to accept and initialize this data. Include setter and getter methods for all instance data. Include a toString method that returns a nicely formatted, multi-line description of the book. Write another class called Bookshelf, which has name and array of Book objects. Bookself capacity is maximum of five books. Includes method for Bookself that adds, removes,...
Book: - title: String - price: double +Book() +Book(String, double) +getTitle(): String +setTitle(String): void +getPrice(): double +setPrice(double): void +toString(): String The class has two attributes, title and price, and get/set methods for the two attributes. The first constructor doesn’t have a parameter. It assigns “” to title and 0.0 to price; The second constructor uses passed-in parameters to initialize the two attributes. The toString() method returns values for the two attributes. Notation: - means private, and + means public. 1....
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...
Implement the classes in the following class diagram. The Book class implements the Comparable interface. Use implements Comparable<Book> in the class definition. Now, all book objects are instances of the java.lang.Comparable interface. Write a test program that creates an array of ten books. 1. Use Arrays.sort( Book[]l books) from the java.util package to sort the array. The order of objects in the array is determined using compareTo...) method. 2. Write a method that returns the most expensive book in the...
Write a class named Book containing: Two instance variables named title and author of type String. A constructor that accepts two String parameters. The value of the first is used to initialize the value of title and the value of the second is used to initialize author. A method named toString that accepts no parameters. toString returns a String consisting of the value of title, followed by a newline character, followed by the value of author.