Description of this paper

IT215 Week 9 Final Bookstore Project Part 6

Description

solution


Question

//IT215 Week 9 Final;//Bookstore Project Part 6;//;import javax.swing.*;import java.awt.event.*;import java.awt.*;import java.io.File;import java.io.FileOutputStream;import java.io.IOException;import java.io.ObjectOutputStream;import java.io.Serializable;import java.text.NumberFormat, //application uses Number Format;import java.util.Locale, //Application uses United States Currenc;public final class Bookstore extends JFrame //Class: Bookstore;final int MAX = 5;Books pt[] = new Books[MAX];int numBooks, //Keeps track of the number of books in the array;int curBooks,// The current number of books;JPanel detailPanel, //JPanels;JPanel navigation;JPanel finalButtons;JLabel lb1, lb2, lb3, lb4, lb5, lb6, lb7, //JLabels 1-7;JTextField tf1, tf2, tf3, tf4, tf5, tf6, tf7, //JTextField 1-7;JButton first, previous, next, last, add, delete, modify, save, search, //JButtons;Bookstore() //Bookstore Constructor;super("Book Store"), //Frame Title;numBooks = 0, //Zero books on initial;curBooks = -1;detailPanel = new JPanel();detailPanel.setLayout(null);first = new JButton("First"), //Navigation "First" button;previous = new JButton("Previous"), //Navigation "Previous" button;next = new JButton("Next"),//Navigation "Next" button;last = new JButton("Last"),//Navigation "Last" button;first.addActionListener(new ActionHandler()), //Actionlistener "First" event button;previous.addActionListener(new ActionHandler()), //Actionlistener "Previous" event button;next.addActionListener(new ActionHandler()), //Actionlistener "Next" event button;last.addActionListener(new ActionHandler()), //Actionlistener "Last" event button;//Navigation panel;navigation = new JPanel();navigation.setLayout(new GridLayout(2,2));navigation.setBounds(150,0,370,150);navigation.add(first);navigation.add(previous);navigation.add(next);navigation.add(last);add(navigation);//JLabels;lb1 = new JLabel("Title"), //Title Label;lb2 = new JLabel("ISBN"), //ISBN Label;lb3 = new JLabel("Price"), //Author's name Label;lb4 = new JLabel("Year"), //Year Published Label;lb5 = new JLabel("Publisher"), //Publisher's name label;lb6 = new JLabel("Author"), //Price of the book label;lb7 = new JLabel("Total"), //Total cost of all books label;//Text fields;tf1 = new JTextField(20), //Title Text field;tf2 = new JTextField(20), //ISBN Text field;tf3 = new JTextField(20), //Author's name Text field;tf4 = new JTextField(20), //Year Published Text field;tf5 = new JTextField(20), //Publisher's name Text field;tf6 = new JTextField(20), //Price of the book Text field;tf7 = new JTextField(20), //Total cost of all books Text field;//Additions for Final Project: buttons;finalButtons = new JPanel();finalButtons.setBounds(0,150,150,350);finalButtons.setLayout(new GridLayout(5,1));add = new JButton("Add");delete = new JButton("Delete");modify = new JButton("Modify");save = new JButton("Save");search = new JButton("Search");//Final Project: buttons Actionlisteners;add.addActionListener(new ActionHandler());delete.addActionListener(new ActionHandler());modify.addActionListener(new ActionHandler());save.addActionListener(new ActionHandler());search.addActionListener(new ActionHandler());finalButtons.add(add);finalButtons.add(delete);finalButtons.add(modify);finalButtons.add(save);finalButtons.add(search);add(finalButtons);setLayout(null);//Set Frame Size;setSize(528,533);setLocation(150,100);setResizable(false);//Panel label positions;lb1.setBounds(20,30,200,25);lb2.setBounds(20,60,200,25);lb3.setBounds(20,90,200,25);lb4.setBounds(20,120,200,25);lb5.setBounds(20,150,200,25);lb6.setBounds(20,180,200,25);lb7.setBounds(20,210,200,25);//Panel Text field positions;tf1.setBounds(240,30,100,25);tf2.setBounds(240,60,100,25);tf3.setBounds(240,90,100,25);tf4.setBounds(240,120,100,25);tf5.setBounds(240,150,100,25);tf6.setBounds(240,180,100,25);tf7.setBounds(240,210,100,25);//Removing ability to manually edit text fields;editText(false);//Setting text field BG color to WHITE;tf1.setBackground(Color.WHITE);tf2.setBackground(Color.WHITE);tf3.setBackground(Color.WHITE);tf4.setBackground(Color.WHITE);tf5.setBackground(Color.WHITE);tf6.setBackground(Color.WHITE);tf7.setBackground(Color.WHITE);//Adding labels to Detail Panel;detailPanel.add(lb1);detailPanel.add(lb2);detailPanel.add(lb3);detailPanel.add(lb4);detailPanel.add(lb5);detailPanel.add(lb6);detailPanel.add(lb7);//Adding TF to Detail Panel;detailPanel.add(tf1);detailPanel.add(tf2);detailPanel.add(tf3);detailPanel.add(tf4);detailPanel.add(tf5);detailPanel.add(tf6);detailPanel.add(tf7);//Setting Detail Panel to frame;detailPanel.setBounds(150,150,370,350);add(detailPanel);setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);setVisible(true);//Total value of all items in inventory;public float total();float total = 0;for(int i=0, i 1);//make curBooks - 1 passes through the array;for(pass=1, pass=1) // array is not empty;int index;String deleteByTitle=null;// prompt for name to delete;deleteByTitle = JOptionPane.showInputDialog(null,"Enter the name to delete");if(deleteByTitle == null);return;index = searchByTitle(deleteByTitle), //search name in the array;if(index != -1);//found;if(numBooks==1) // present at first position;pt[0] = null, //delete;else;for(int i=index,i

 

Paper#70040 | Written in 18-Jul-2015

Price : $27
SiteLock