Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package library;
- /**
- *
- * @author Lowe
- */
- public class Book {
- private int storage;
- private String isbn;
- private String title;
- private static int counter = 1000;
- public Book( String title, String isbn, int initStorage){
- this.title = title;
- this.isbn= isbn;
- this.storage = storage;
- }
- public void returnB(int amount){
- this.storage += amount;
- }
- public void lend(int amount){
- if(storage > amount){
- this.storage -= amount;
- }
- }
- public int storage(){
- return storage;
- }
- public String isbn(){
- return isbn;
- }
- public String title(){
- return title;
- }
- }
- package library;
- import java.util.*;
- /**
- *
- * @author Lowe
- */
- public class Library {
- private final ArrayList books = new ArrayList();
- /**
- * @param args the command line arguments
- */
- public void addBook(Book b){
- books.add(b);
- }
- public Book findBook(String isbn){
- for(int i=0; i<books.size() ; i++){
- Book temp = (Book)books.get(i);
- if(temp.isbn()==isbn){
- return temp;
- }
- }
- return null;
- }
- }
- package library;
- /**
- *
- * @author Lowe
- */
- public class LibrarySystem {
- public static void main(String[] args){
- Library libraryN = new Library();
- Gui gui = new Gui(libraryN);
- }
- }
- package library;
- /**
- *
- * @author Lowe
- */
- import java.awt.*;
- import java.awt.event.*;
- import javax.swing.*;
- import java.io.*;
- public class Gui {
- private JFrame frame = new JFrame("Bibblan");
- private JPanel background, centerPanel, southPanel;
- private JLabel l_isbn,l_title, l_reclaim,l_lend,l_storage;
- private JTextField tf_isbn,tf_title, tf_reclaim,tf_lend,tf_storage;
- private JButton b_find,b_reclaim,b_lend,b_clear,b_newBook,b_save,b_load;
- private Book findB;
- private Library libraryN;
- public Gui(Library l){
- libraryN = l;
- background = new JPanel();
- background.setLayout((new BorderLayout()));
- centerPanel = new JPanel();
- background.setBorder(BorderFactory.createLineBorder(Color.BLUE,9,false));
- centerPanel.setLayout((new GridLayout(5,2)));
- southPanel = new JPanel();
- southPanel.setLayout((new GridLayout(3,2)));
- b_find = new JButton("find");
- b_reclaim = new JButton("return");
- b_lend = new JButton("lend");
- b_clear = new JButton("clear");
- b_newBook = new JButton("Add");
- b_save = new JButton("save");
- b_load = new JButton("load");
- southPanel.add(b_find);
- southPanel.add(b_reclaim);
- southPanel.add(b_lend);
- southPanel.add(b_clear);
- southPanel.add(b_newBook);
- southPanel.add(b_save);
- southPanel.add(b_load);
- l_isbn = new JLabel("isbn:");
- l_title = new JLabel("title:");
- l_reclaim = new JLabel("return:");
- l_lend = new JLabel("lend:");
- l_storage = new JLabel("storage:");
- tf_isbn = new JTextField(12);
- tf_title = new JTextField(12);
- tf_reclaim = new JTextField(12);
- tf_lend = new JTextField(12);
- tf_storage = new JTextField(12);
- centerPanel.add(l_isbn);
- centerPanel.add(tf_isbn);
- centerPanel.add(l_title);
- centerPanel.add(tf_title);
- centerPanel.add(l_reclaim);
- centerPanel.add(tf_reclaim);
- centerPanel.add(l_lend);
- centerPanel.add(tf_lend);
- centerPanel.add(l_storage);
- centerPanel.add(tf_storage);
- frame.setContentPane(background);
- frame.pack();
- frame.setVisible(true);
- ClearHandler cl = new ClearHandler();
- FindHandler fh = new FindHandler();
- this.b_clear.addActionListener(cl);
- this.b_lend.addActionListener(new LE());
- this.b_reclaim.addActionListener(new RE());
- this.b_find.addActionListener(fh);
- this.b_addNB.addActionListener(new addNB());
- this.libraryN = libraryN;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement