Language C You are to create a program that can be used for

Language: C++

You are to create a program that can be used for keeping track of textbooks required and recommended for classes and the cost of those textbooks. All input will be taken from standard input. Each line of input will begin with a single or double character code that identifies the type of operation that line describes. The possible line formats are: B Define a book. The ISBN is a 13 digit number. The Title is a string of arbitrary length (ending with a line break) e.g.: B 1234567890123 Programming for Programmers D

Solution

public class Library {

    private ArrayList<Book> allBook = new ArrayList<Book>();

    public Library(ArrayList<Book> other) {

        if (other == null) {

            throw new NullPointerException(\"null pointer\");

        } else

            this.allBook = other;

    }

    public Library() {

        this.allBook = new ArrayList<Book>();

    }

    public boolean add(Book book) {

        if (book != null && !book.equals(\"\")) {

            throw new IllegalArgumentException(\"Can\'t be empty\");

        }

        allBook.add(book);

        return true;

    }

    public ArrayList<Book> findTitles(String title) {

        for(Book b: allBook) {

            if(title.compareTo(b.getTitle())== 0) {

                return allBook;

            }

        }

        return null;

    }

    public void sort() {

        Collections.sort(allBook);

    }

    public String toString() {

        return Library.this.toString();

    }

}

    public class Book implements Comparable<Book> {

    private String bookTitle;

   private ArrayList<String> bookAuthor;

    public Book(String title, ArrayList<String> authors) {

        if(title == null && authors == null) {

            throw new IllegalArgumentException(\"Can\'t be null\");

        }

        if(title.isEmpty() && authors.isEmpty()) {

            throw new IllegalArgumentException(\"Can\'t be empty\");

        }

        bookTitle = title;

        bookAuthor = authors;

    }

    public String getTitle() {

        return bookTitle;

    }

    public ArrayList<String> getAuthors( ) {

        return bookAuthor;

    }

    public String toString( ) {

        return bookTitle + bookAuthor;

    }

    public int compareTo(Book other){

        return bookTitle.compareTo(other.bookTitle);

    }

    public boolean equals(Object o) {

         if(!(o instanceof Book)) {

             return false;

        }

         Book b = (Book) o;

         return b.bookTitle.equals(bookTitle)

                 && b.bookAuthor.equals(bookAuthor);

    }

}

Language: C++ You are to create a program that can be used for keeping track of textbooks required and recommended for classes and the cost of those textbooks.
Language: C++ You are to create a program that can be used for keeping track of textbooks required and recommended for classes and the cost of those textbooks.
Language: C++ You are to create a program that can be used for keeping track of textbooks required and recommended for classes and the cost of those textbooks.

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site