Fall 2020: CS 203 - Object-Oriented Programming Assignment 5 Book Store Application XXXXXXXXXXdue on November 22, 2020 Objectives: • To practice Java GUI using Swing Book Store Application In this...

1 answer below »
I need help finishing my homework


Fall 2020: CS 203 - Object-Oriented Programming Assignment 5 Book Store Application due on November 22, 2020 Objectives: • To practice Java GUI using Swing Book Store Application In this homework, we will be creating a software for a small bookstore in the neighborhood. The manager of the bookstore needs a computer program to keep record of the inventory and the rented books. The program should be able to perform the following operations: • Display a list of all of the books in the store (full information) [20 points] • Search a book by title and show the details of a particular book (title, author, number of pages, publisher, copies in the inventory) [20 points] • Rent a book [20 points] • Display a list of all of the bookstore’s customers (full information) [20 points] • Search a customer by name and display the details of a particular customer (firstname, lastname, email address, phone number) [20 points] • Display a list of all of the books rented by a particular customer – by last name o Display the names and authors of the books [bonus +20 points] Hints: • You will need three different list: o A list of all of the books in the store o A list of all of the customers of the store o A list of the books currently rented by the customers • You need to read keep the records in a txt file (read from file/ write to file) • You should decide the required/useful components to include. • Assume, I am your customer and don’t have a CS background. Thus, you shouldn’t expect detailed information from me. Additionally, you need to design a simple and effective GUI that I can use • Your homework will be graded by the functionality. Firstly, create something that is working without any issue, then you can improve/beautify the GUI. • It is your task to identify the necessary classes, attributes and methods. Homework Submission Instructions You can work with a friend (group of two), or you can do it alone. • Deliverables: o A well written project report (.pdf) § Explain your classes, attributes and methods. Explain how you implemented the Inheritance, and benefits of this implementation § Put the screenshots of your outputs (the working version of your code) o Project.zip file § Submit the working version of the whole project file § Do not submit only the classes o Independent/group completion form • Submit your files to Canvas (other submission methods will not be accepted) If any of the problem statements is unclear, use the Canvas discussion board to ask for clarifications. Fall 2020: CS 203 - Object-Oriented Programming Assignment 5 Book Store Application due on November 22, 2020 Objectives: • To practice Java GUI using Swing Book Store Application In this homework, we will be creating a software for a small bookstore in the neighborhood. The manager of the bookstore needs a computer program to keep record of the inventory and the rented books. The program should be able to perform the following operations: • Display a list of all of the books in the store (full information) [20 points] • Search a book by title and show the details of a particular book (title, author, number of pages, publisher, copies in the inventory) [20 points] • Rent a book [20 points] • Display a list of all of the bookstore’s customers (full information) [20 points] • Search a customer by name and display the details of a particular customer (firstname, lastname, email address, phone number) [20 points] • Display a list of all of the books rented by a particular customer – by last name o Display the names and authors of the books [bonus +20 points] Hints: • You will need three different list: o A list of all of the books in the store o A list of all of the customers of the store o A list of the books currently rented by the customers • You need to read keep the records in a txt file (read from file/ write to file) • You should decide the required/useful components to include. • Assume, I am your customer and don’t have a CS background. Thus, you shouldn’t expect detailed information from me. Additionally, you need to design a simple and effective GUI that I can use • Your homework will be graded by the functionality. Firstly, create something that is working without any issue, then you can improve/beautify the GUI. • It is your task to identify the necessary classes, attributes and methods.
Answered Same DayDec 01, 2021

Answer To: Fall 2020: CS 203 - Object-Oriented Programming Assignment 5 Book Store Application XXXXXXXXXXdue on...

Aditya answered on Dec 03 2021
157 Votes
New folder/AddBook.java
New folder/AddBook.java
import javax.swing.JOptionPane;
public class AddBook extends javax.swing.JFrame {
    /**
     * Creates new form AddBook
     */
    public AddBook() {
        initComponents();
    }
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // //GEN-BEGIN:initComponents
    private void initComponents() {
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        Title = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        Author = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        Publisher = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        Page = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        Copies = new javax.swing.JTextField();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        jLabel1.setText("Book Information");
        jLabel2.setText("Title");
        jLabel3.setText("Author");
        jLabel4.setText("Publisher");
        jLabel5.setText("Pages");
        jLabel6.setText("Copies");
        jButton1.setText("Add Book");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
        jButton2.setText("Back");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(43, 43, 43)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel3)
                    .addGroup(layout.createSequentialGroup()
 
          .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel4)
                            .addComponent(jLabel2)
                            .addComponent(jLabel5)
                            .addComponent(jLabel6))
                        .addGap(61, 61, 61)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jLabel1)
                            .addComponent(Title)
                            .addComponent(Author)
                            .addComponent(Publisher)
                            .addComponent(Page)
                            .addComponent(Copies)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jButton1)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 55, Short.MAX_VALUE)
                                .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                .addContainerGap(48, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(33, 33, 33)
                .addComponent(jLabel1)
                .addGap(25, 25, 25)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(Title, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(Author, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(Publisher, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(Page, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(Copies, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton1)
                    .addComponent(jButton2))
                .addContainerGap(50, Short.MAX_VALUE))
        );
        pack();
    }// //GEN-END:initComponents
    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        // TODO add your handling code here:
        BookStore bookStore = new BookStore();
        bookStore.setVisible(true);
        this.dispose();
    }//GEN-LAST:event_jButton2ActionPerformed
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
        String title = Title.getText();
        String author = Author.getText();
        String publisher = Publisher.getText();
        String copy = Copies.getText();
        String page = Page.getText();
        if(title.isEmpty() || author.isEmpty() || publisher.isEmpty() || copy.isEmpty() || page.isEmpty())
        {
            JOptionPane.showMessageDialog(this, "Fill all the information");
        }
        else
        {
            try
            {
                int nummbberOfPages = Integer.parseInt(page);
                int copies = Integer.parseInt(copy);
                Book book = new Book(title, author, nummbberOfPages, publisher, copies);
                Manager manager = Manager.getInstance();
                manager.addBook(book);
                int id = book.getBookID();
                JOptionPane.showMessageDialog(this, "Book is added to Book Store: "+id);
                BookStore bookStore = new BookStore();
                bookStore.setVisible(true);
                this.dispose();
            }
            catch(NumberFormatException e)
            {
                JOptionPane.showMessageDialog(this, "Enter valid integer values for number of copies or page");
                Copies.setText("");
                Page.setText("");
            }
        }
    }//GEN-LAST:event_jButton1ActionPerformed
    /**
     * @param args the command line arguments
     */

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextField Author;
    private javax.swing.JTextField Copies;
    private javax.swing.JTextField Page;
    private javax.swing.JTextField Publisher;
    private javax.swing.JTextField Title;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    // End of variables declaration//GEN-END:variables
}
New folder/AddCustomer.java
New folder/AddCustomer.java
import javax.swing.JOptionPane;
public class AddCustomer extends javax.swing.JFrame {
    /**
     * Creates new form AddCustomer
     */
    public AddCustomer() {
        initComponents();
    }
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // //GEN-BEGIN:initComponents
    private void initComponents() {
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        first = new javax.swing.JTextField();
        last = new javax.swing.JTextField();
        email = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        phone = new javax.swing.JTextField();
        AddCustomerButton = new javax.swing.JButton();
        backButton = new javax.swing.JButton();
        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        jLabel1.setText("Customer Information");
        jLabel2.setText("First Name");
        jLabel3.setText("Last Name");
        jLabel4.setText("Email Address");
        jLabel5.setText("Phone Number");
        AddCustomerButton.setText("Add Customer");
        AddCustomerButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                AddCustomerButtonActionPerformed(evt);
            }
        });
        backButton.setText("Back");
        backButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                backButtonActionPerformed(evt);
            }
        });
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(139, 139, 139)
                        .addComponent(jLabel1))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(37, 37, 37)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel3)
                            .addComponent(jLabel2)
                            .addComponent(jLabel4)
                            .addComponent(jLabel5))
                        .addGap(49, 49, 49)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(AddCustomerButton)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 54, Short.MAX_VALUE)
                                .addComponent(backButton))
                            .addComponent(first)
                            .addComponent(last)
                            .addComponent(email)
                            .addComponent(phone))))
                .addContainerGap(34, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(28, 28, 28)
                .addComponent(jLabel1)
                .addGap(27, 27, 27)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(first, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(last, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(email, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(phone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(AddCustomerButton)
                    .addComponent(backButton))
                .addContainerGap(77, Short.MAX_VALUE))
        );
        pack();
    }// //GEN-END:initComponents
    private void backButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_backButtonActionPerformed
        // TODO add your handling code here:
        BookStore bookStore = new BookStore();
        bookStore.setVisible(true);
        this.dispose();
    }//GEN-LAST:event_backButtonActionPerformed
    private void AddCustomerButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_AddCustomerButtonActionPerformed
        // TODO add your handling code here:
        String firstName = first.getText();
        String lastName = last.getText();
        String emailAddress = email.getText();
        String number = phone.getText();
        if(firstName.isEmpty() || lastName.isEmpty() || emailAddress.isEmpty() || number.isEmpty())
        {
            JOptionPane.showMessageDialog(this, "Fill all the Details");
        }
        else
        {
            try
            {
                int phoneNumber = Integer.parseInt(number);
                Customer customer = new Customer(firstName, lastName, emailAddress, phoneNumber);
                Manager manager = Manager.getInstance();
                manager.addCustomer(customer);
                int id = customer.getCustomerId();
                JOptionPane.showMessageDialog(this, "New Customer is added with id: "+id);
                BookStore bookStore = new BookStore();
                bookStore.setVisible(true);
                this.dispose();
            }
            catch(NumberFormatException e)
            {
                JOptionPane.showMessageDialog(this, "Enter a valid phone number");
                phone.setText(null);
            }
        }
    }//GEN-LAST:event_AddCustomerButtonActionPerformed
    /**
     * @param args the command line arguments
     */

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton AddCustomerButton;
    private javax.swing.JButton backButton;
    private javax.swing.JTextField email;
    private javax.swing.JTextField first;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JTextField last;
    private javax.swing.JTextField phone;
    // End of variables declaration//GEN-END:variables
}
New folder/Book.java
New folder/Book.java
public class Book {
    private int bookID;
    private String title;
    private String author;
    private int numberOfPage;
    private String publisher;
    private int copies;
    private static int autoId = 2001;
    public Book(String title, String author, int numberOfPage, String publisher, int copies) {
        this.title = title;
        this.author = author;
        this.numberOfPage = numberOfPage;
        this.publisher = publisher;
        this.copies = copies;
        this.bookID = autoId;
        autoId++;
    }
    @Override
    public String toString() {
        return "Book{" + "bookID=" + bookID + ", title=" + title + ", author=" + author + ", numberOfPage=" + numberOfPage + ", publisher=" + publisher + ", copies=" + copies + '}';
    }
    public String getBookInformation()
    {
        String text = "Book ID: "+bookID+"\nTitle: "+title+"\nAuthor: "+author+"\nNumber Of Pages: "+numberOfPage+"\nPublisher: "+publisher+"\nCopies: "+copies;
        return text;
    }

    public String getFileData()
    {
        String data = title+"%"+author+"%"+numberOfPage+"%"+publisher+"%"+copies;
        return data;
    }

    public void issueBook()
    {
        this.copies --;
    }

    public void returnBook()
    {
       this.copies++;
    }

    public int getBookID() {
        return bookID;
    }
    public String getTitle() {
        return title;
    }
    public String getAuthor() {
        return author;
    }
    public int getNumberOfPage() {
        return numberOfPage;
    }
    public String getPublisher() {
        return publisher;
    }
    public int getCopies() {
        return copies;
    }





}
New folder/BookRentedByCustomer.java
New folder/BookRentedByCustomer.java
import java.util.ArrayList;
import javax.swing.JOptionPane;
/*
 * 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.
 */
/**
 *
 * @author Aditya
 */
public class BookRentedByCustomer extends javax.swing.JFrame {
    /**
     * Creates new form BookRentedByCustomer
     */
    public BookRentedByCustomer() {
        initComponents();
    }
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // //GEN-BEGIN:initComponents
    private void initComponents() {
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        lastName = new javax.swing.JTextField();
        search = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        bookInformation = new javax.swing.JTextArea();
        back = new javax.swing.JButton();
        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        jLabel1.setText("Book Rented By Customer");
        jLabel2.setText("Enter Last Name: ");
        search.setText("Search");
        search.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                searchActionPerformed(evt);
            }
        });
        bookInformation.setEditable(false);
        bookInformation.setColumns(20);
        bookInformation.setRows(5);
        jScrollPane1.setViewportView(bookInformation);
        back.setText("Back");
        back.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                backActionPerformed(evt);
            }
        });
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jScrollPane1))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(129, 129, 129)
                        .addComponent(jLabel1)
                        .addGap(0, 136, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(lastName)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(search))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(back)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(lastName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(search))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 187, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(back)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        pack();
    }// //GEN-END:initComponents
    private void backActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_backActionPerformed
        // TODO add your handling code here:
        BookStore bookStore = new BookStore();
        bookStore.setVisible(true);
        this.dispose();
    }//GEN-LAST:event_backActionPerformed
    private void searchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_searchActionPerformed
        // TODO add your handling code here:
        String lastName = this.lastName.getText();
        if(lastName.isEmpty() || lastName == "")
        {
            JOptionPane.showMessageDialog(this, "");
        }
        else
        {
            Manager manager = Manager.getInstance();
            Customer customer = manager.getCustomerByLastName(lastName);
            if(customer == null)
            {
                JOptionPane.showMessageDialog(this, "No Customer Exists with this Last Name");
                this.lastName.setText("");
            }
            else
            {
                ArrayList bookList = customer.getRentedBooks();
                if(bookList.isEmpty())
                {
                    bookInformation.setText("No Book is rented by this customer");
                }
                else
                {
                    String text = "Rented Book Informations \n\n";
                    for(int i =0;i                    {
                        String data = "Book Name: "+bookList.get(i).getTitle()+"\nAuthor: "+bookList.get(i).getAuthor();
                        text = text + data + "\n\n";
                    }
                    bookInformation.setText(text);
                }
            }
        }
    }//GEN-LAST:event_searchActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton back;
    private javax.swing.JTextArea bookInformation;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextField lastName;
    private javax.swing.JButton search;
    // End of variables declaration//GEN-END:variables
}
New folder/BookStore.java
New...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here