图书信息管理系统Java

要求:

图书信息包括:登录号、书名、作者名、分类号、出版单位、出版时间、价格等。

试设计一图书信息管理系统,使之能提供以下功能:

1、系统以菜单方式工作

2、图书信息录入功能--输入

3、图书信息浏览功能--输出

4、图书信息查询功能--算法

查询方式

 按书名查询

 按作者名查询

5、图书信息的删除与修改(可选项)

源代码:

Library.java:

class Library {
    String Login_number;
    String Book_name;
    String Author_name;
    String Classification_name;
    String Publish_unit;
    String Publish_time;
    double Price;
    Library(String login_number,String book_name,String author_name,String classification_name,String publish_unit,String publish_time,double price)
    {
        Login_number = login_number;
        Book_name = book_name;
        Author_name = author_name;
        Classification_name = classification_name;
        Publish_unit = publish_unit;
        Publish_time = publish_time;
        Price = price;
    }
    public String getlogin_number()
    {
        return Login_number;
    }
    public String getBook_name()
    {
        return Book_name;
    }
    public String getAuthor_name()
    {
        return Author_name;
    }
    public String getClassification_name()
    {
        return Classification_name;
    }
    public String getPublish_unit()
    {
        return Publish_unit;
    }
    public String getPublish_time()
    {
        return Publish_time;
    }
    public double getPrice()
    {
        return Price;
    }
}

 

LibraryMenu.java:

import java.awt.*;
import java.awt.event.*;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;

import javax.swing.*;
import javax.swing.table.DefaultTableModel;
public class LibraryMenu extends JFrame{
    //private Frame f = new Frame("图书信息管理系统");
    private MenuBar mb = new MenuBar();
    Menu submit = new Menu("录入");
    Menu scan = new Menu("浏览");
    Menu search = new Menu("查询");
    Menu file = new Menu("文件操作");
    MenuItem BookNameSearch = new MenuItem("书名",new MenuShortcut(KeyEvent.VK_3));
    MenuItem AuthorSearch = new MenuItem("作者名",new MenuShortcut(KeyEvent.VK_4));
    MenuItem input = new MenuItem("录入",new MenuShortcut(KeyEvent.VK_1));
    MenuItem Scan = new MenuItem("浏览",new MenuShortcut(KeyEvent.VK_2));
    MenuItem delete = new MenuItem("删除");
    MenuItem modify = new MenuItem("修改"); 
    JTable table;
           
    //主菜单
    LibraryMenu() throws FileNotFoundException
    {
        
        String []columntitle = new String[]{"登入号","书名","作者名","分类号","出版单位","出版时间","价钱"};     
         int row = Read.read().length;
         String [][]S = new String[row][7];
         S = Read.read();
         Object [][]Date = new String[row][7];
         for(int i=0;i

Write.java:

import java.awt.Frame;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

public class Write {
	public static void write(Library a) throws IOException {
		File file = new File("Library.txt"); 
		FileWriter out = new FileWriter(file,true); //可追加数据
		out.write(a.getlogin_number()+" ");
		out.write(a.getBook_name()+" ");
		out.write(a.getAuthor_name()+" ");
		out.write(a.getClassification_name()+" ");
		out.write(a.getPublish_unit()+" ");
		out.write(a.getPublish_time()+" ");
		out.write(String.valueOf(a.getPrice())+" ");
		out.write("\r\n");
		out.flush();
		out.close();
		
	}

Read.java:

import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;

public class Read {
	public static String[][] read() throws FileNotFoundException{
		File file=new File("Library.txt");		
	    Scanner input = new Scanner(file);
	    String []A = new String[10000];
	    int k=0;
	    while(input.hasNext()){
	    	String str = String.valueOf(input.next());
	    	A[k] = str;
	    	k++;
	    }
	    int row = k/7;
	    int col = 7;
	    int t = 0;
	    String [][]B = new String[row][col];
	    for(int i=0;i

ClickSubmit.java:

import java.awt.Button;
import java.awt.Choice;
import java.awt.TextField;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;

import javax.swing.Box;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class ClickSumbit {
	private JFrame frame = new JFrame("录入");
	private JLabel login_number = new JLabel("    登入号: ");
	private TextField input_number1 = new TextField(10);
	private JLabel book_name = new JLabel("    书名: ");
	private TextField input_number2 = new TextField(10);
	private JLabel Author_name = new JLabel("    作者名: ");
	private TextField input_number3 = new TextField(10);
	private JLabel Classification_name = new JLabel("    分类号: ");
	private Choice input_number4 = new Choice();
	private JLabel Publish_unit = new JLabel("    出版单位: ");
	private TextField input_number5 = new TextField(10);
	private JLabel Publish_time = new JLabel("    出版时间: ");
	private TextField input_number6 = new TextField(10);
	private JLabel Price = new JLabel("    价格: ");
	private TextField input_number = new TextField(10);
	private JLabel backnapse = new JLabel("     ");
	private Button confirm = new Button("确认");
	private Button reset = new Button("重置");
	Box box1 = Box.createHorizontalBox();
	Box box2 = Box.createHorizontalBox();
	Box box3 = Box.createHorizontalBox();
	Box box4 = Box.createHorizontalBox();
	Box box5 = Box.createHorizontalBox();
	Box box6 = Box.createHorizontalBox();
	Box box7 = Box.createHorizontalBox();
	Box box8 = Box.createHorizontalBox();
	Box boxV = Box.createVerticalBox();	
	String [] a = {"A(马克思主义等)","B(哲学,宗教)","C(社会科学总论)","D(政治)","E(军事)","F(经济)"
			,"G(文化,科学,教育)","H(语言)","I(文学)","J(艺术)","K(历史)","Z(综合性问题)"};
	ClickSumbit() {
		for(int i=0;i

Modify.iava:

import java.awt.Button;
import java.awt.Choice;
import java.awt.TextField;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;

import javax.swing.Box;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class Modify {
	private JFrame frame = new JFrame("修改");
	private JLabel label = new JLabel("请输入你想要的修改其信息的登入号:");
	private TextField modify = new TextField(10);
	private JLabel login_number = new JLabel("    新登入号: ");
	private TextField input_number1 = new TextField(10);
	private JLabel book_name = new JLabel("    新书名: ");
	private TextField input_number2 = new TextField(10);
	private JLabel Author_name = new JLabel("    新作者名: ");
	private TextField input_number3 = new TextField(10);
	private JLabel Classification_name = new JLabel("    新分类号: ");
	private Choice input_number4 = new Choice();
	private JLabel Publish_unit = new JLabel("    新出版单位: ");
	private TextField input_number5 = new TextField(10);
	private JLabel Publish_time = new JLabel("    新出版时间: ");
	private TextField input_number6 = new TextField(10);
	private JLabel Price = new JLabel("    新价格: ");
	private TextField input_number = new TextField(10);
	private Button confirm = new Button("确认");
	private Button reset = new Button("重置");
	private JLabel backnapse = new JLabel("     ");
	Box box1 = Box.createHorizontalBox();
	Box box2 = Box.createHorizontalBox();
	Box box3 = Box.createHorizontalBox();
	Box box4 = Box.createHorizontalBox();
	Box box5 = Box.createHorizontalBox();
	Box box6 = Box.createHorizontalBox();
	Box box7 = Box.createHorizontalBox();
	Box box8 = Box.createHorizontalBox();
	Box box9 = Box.createHorizontalBox();
	Box boxV = Box.createVerticalBox();	
	Modify() {
		String [] a = {"A(马克思主义等)","B(哲学,宗教)","C(社会科学总论)","D(政治)","E(军事)","F(经济)"
				,"G(文化,科学,教育)","H(语言)","I(文学)","J(艺术)","K(历史)","Z(综合性问题)"};
		for(int i=0;i

LibrianInforManager.java

import java.io.FileNotFoundException;

public class LibrianInforManager {

	public static void main(String[] args) throws FileNotFoundException {
		LibraryMenu menu = new LibraryMenu();
		menu.setTitle("图书管理系统");
		menu.setBounds(200, 150, 800, 400);
		menu.setDefaultCloseOperation(1);
		menu.setVisible(true);
	}

}

效果截图:

图书信息管理系统Java_第1张图片
 

图书信息管理系统Java_第2张图片

图书信息管理系统Java_第3张图片

你可能感兴趣的:(图书信息管理系统Java)